issue 7006 - std.math.pow (integral, integral) crashes on negative exponents

jmh530 john.michael.hall at gmail.com
Mon Dec 16 15:13:44 UTC 2019


On Monday, 16 December 2019 at 15:00:47 UTC, jmh530 wrote:
> 
>
> I don't doubt that (-1)^i, where i is an iterator, is useful in 
> many, many cases. However, you would need for pow(int, int) to 
> return a complex number all the time, if you want to handle 
> that use case, not just when i<0. That will make a lot of other 
> code a lot more complicated. It is much simpler to convert -1 
> to complex and then call pow(complex, int) and return a complex 
> number. That means that whether i=1 or i=2, the result is 
> complex. That will make your life a lot less complicated, 
> particularly if you pass that result to other functions.

What I mean is that if i is 0.5, then you have to return a 
complex. So you have to add a special case for that.


More information about the Digitalmars-d mailing list