- Perl 6 Deep Dive
- Andrew Shitov
- 67字
- 2021-07-03 00:05:50
Calculating the square root of the value
To calculate the square root of the value, call the sqrt method on it:
say 9.sqrt; # 3
The routine is also defined in Perl 6 as a standalone built-in function. Consider the following code snippet:
say sqrt(9); # 3
As the sqrt method is inherited from the Numeric role, the result is a floating-point value:
say 10.sqrt; # 3.16227766016838