In Operators§

See primary documentation in context for infix **

multi infix:<**>(Any, Any --> Numeric:D) is assoc<right>

The exponentiation operator coerces both arguments to Numeric and calculates the left-hand-side raised to the power of the right-hand side.

If the right-hand side is a non-negative integer and the left-hand side is an arbitrary precision type (Int, FatRat), then the calculation is carried out without loss of precision.

Unicode superscripts will behave in exactly the same way.

sub squared( Int $num ) { $num² };
say squared($_) for ^5; # OUTPUT: «0␤1␤4␤9␤16␤»

It also works for sequences of several Unicode superscript numbers:

sub twenty-second-power( Int $num ) { $num²² };
say twenty-second-power($_) for ^5; # OUTPUT: «0␤1␤4194304␤31381059609␤17592186044416␤»