On Sat, 10 Sep 2016 23:17:33 -0700, [email protected] wrote:
> Comparison table of the different cases of "zero to the zeroeth power"
> in Rakudo:
> 
> n        n**0        0**n        n**n
> -------------   ---------   ---------   ---------
> 0           1           1           1
> 0.0           1           1           1
> FatRat.new(0)           1           1           1
> 0e0           1           1           1
> 0+0i   NaN+NaN\i   NaN+NaN\i        0+0i
> 
> I think that's a pretty clear indication that the Complex case is in
> need of fixing.
> I'm just not sure which way:
> 
> - either make all entries in the bottom row produce 1+0i       (like
> Perl 5, Python, Ruby)
> - or     make all entries in the bottom row produce NaN+NaN\i  (like
> C++)
> 
> Again, input from someone well versed in math programming would be
> great.

Thanks for the report.

The 0+0i case was returned because the case that does "zero to any power is 
zero" did not consider the power of zero. The NaNs in our case (and I suspect 
in C's case) are due to intermediary math operations involving logs and log(0) 
is a -Inf, which the rest of operations mangled further into a NaN

Fixed for all cases to return 1+0i in: 
https://github.com/rakudo/rakudo/commit/7f322436c9
Tests added in: https://github.com/perl6/roast/commit/6cf2e012c2


Reply via email to