# New Ticket Created by Brad Gilbert
# Please include the string: [perl #130299]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=130299 >
say i ** 3; # -1.83697019872103e-16-1i
say i * i * i; # -0-1i
my Complex $acc;
$acc *= i for 1..3;
say $acc; # -0-1i
Currently it is handled by
multi sub infix:<**>(Complex:D \a, Num(Real) \b) returns Complex:D {
b == 0e0 ?? Complex.new(1e0, 0e0) !! (b * a.log).exp
}
Which I think would be necessary for negative Ints ( I don't know enough about
Complex numbers )
I came across this when creating a golf entry for
https://codegolf.stackexchange.com/questions/102059/complex-binary-numbers/102523#102523
*.base(2).comb(/1+/).map(i***.chars).sum
I had to go with the following instead
*.base(2).comb(/1+/).map({[*] i xx.chars}).sum