role Real
src
role Real does Numeric { ... }
Common role for non-Complex numbers.
Methods
Rat
method Rat(Real:D: Real $epsilon = 1e-6)
Converts the number to a Rat with the precision $epsilon .
rand
sub term:<rand> returns Num:D
method rand(Real:D:) returns Real:D
Returns a pseudo-random number between zero and the number.
The term form returns a pseudo-random Num between 0e0 and 1e0.
sign
method sign(Real:D:)
Returns -1 if the number is negative, 0 if it is zero and 1
otherwise.
round
method round(Real:D: $scale = 1)
Rounds the number to scale $scale . If $scale is 1, rounds to an
integer. If scale is 0.1 , rounds to one digit after the comma etc.
floor
method floor(Real:D) returns Int:D
Return the largest integer not greater than the number.
ceiling
method ceiling(Real:D) returns Int:D
Returns the smallest integer not less than the number.
truncate
method truncate(Real:D) returns Int:D
Rounds the number towards zero.
base
method base(Real:D: Int:D $base where 2..36) returns Str:D
Converts the number to a string, using $base as base. For $base larger
than ten, capital latin letters are used.
255.base(16) # 'FF'