See Original text in context
multi sub log2(Numeric)multi method log2(Numeric:)
Calculates the logarithm to base 2. Returns NaN
for negative arguments and -Inf
for 0
.
See Original text in context
multi method log2()multi sub log2(Numeric )multi sub log2(Cool )
Coerces the invocant to Numeric, and returns its Logarithm in base 2, that is, a number that approximately (due to computer precision limitations) produces the original number when 2 is raised to its power. Returns NaN
for negative arguments and -Inf
for 0
.
say log2(5); # OUTPUT: «2.321928094887362»say "4".log2; # OUTPUT: «2»say 4.log2; # OUTPUT: «2»