Skip to content

Commit 01c7418

Browse files
committed
Complex exponentiation involving zeros #2632
1 parent 2bee5b7 commit 01c7418

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Type/Complex.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ coercion L<fails|/routine/fail> with C<X::Numeric::Real>.
206206
The C<:D> variant returns the result of that coercion. The C<:U> variant issues
207207
a warning about using an uninitialized value in numeric context and then returns value C<0e0>.
208208
209+
=head2 sub infix:<**>
210+
211+
multi sub infix:<**>(Complex:D \a, Complex:D \b --> Complex:D)
212+
multi sub infix:<**>(Num(Real) \a, Complex:D \b --> Complex:D)
213+
multi sub infix:<**>(Complex:D \a, Num(Real) \b --> Complex:D)
214+
215+
The X<exponentiation operator> coerces the second argument to L<Complex|/type/Complex>
216+
and calculates the left-hand-side raised to the power of the right-hand side (both can
217+
be equal to zero).
218+
219+
say i ** i # OUTPUT: «0.20787957635076193+0i␤»
220+
say 2 ** i # OUTPUT: «0.7692389013639721+0.6389612763136348i␤»
221+
say i ** 2 # OUTPUT: «-1+1.2246467991473532e-16i␤»
222+
say 0 ** 1 # OUTPUT: «0+0i␤»
223+
209224
=end pod
210225

211226
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)