routine truncate
1 | class Complex |
1.1 | (Complex) method truncate |
2 | role Real |
2.1 | (Real) method truncate |
3 | class Cool |
3.1 | (Cool) routine truncate |
Documentation for routine truncate
assembled from the following types:
class Complex
From Complex
(Complex) method truncate
Defined as:
method truncate(Complex: --> Complex)
Removes the fractional part of both the real and imaginary parts of the number, using Real.truncate, and returns the result as a new Complex
.
say (1.2-3.8i).truncate; # OUTPUT: «1-3i»
role Real
From Real
(Real) method truncate
method truncate(Real --> Int)
Rounds the number towards zero.
class Cool
From Cool
(Cool) routine truncate
Defined as:
multi sub truncate(Numeric(Cool))multi method truncate()
Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it towards zero.
say 1.2.truncate; # OUTPUT: «1»say truncate -1.2; # OUTPUT: «-1»