issue 7006 - std.math.pow (integral, integral) crashes on negative exponents
jmh530
john.michael.hall at gmail.com
Mon Dec 16 15:57:13 UTC 2019
On Monday, 16 December 2019 at 15:49:35 UTC, Patrick Schluter
wrote:
> [snip]
>
> Why can't that pow(int, int) function implement that workaround
> and return 0 on all negative exponents and not crash otherwise?
> That a function balks at mathematically nonsense values like
> 1/0 or 0^^0 ok, it's expected. That it does so on a function
> that mathematically has valid parameters (even if the result
> can not be represented) is not normal. Nobody expects 2^^70 to
> crash with divide by 0 error unless explicitly requesting
> checked integers that catch overflows.
I think I made some mistakes earlier because I kept mixing stuff
up. Particularly because an exponent of 0.5 wouldn't matter with
ints.
It wouldn't return 0 on all negative exponents. For -2 and more
negative, it should return always 0. For -1, it would return zero
if x is -2 or smaller and otherwise 1 or -1 depending on whether
the exponent is odd or even.
More information about the Digitalmars-d
mailing list