truncate
ErrorsCollection

truncate

Synthesised documentation from type/Real type/Cool type/Complex

From type/Real

See Original text in context

method truncate(Real:D: --> Int:D)

Rounds the number towards zero.

From type/Cool

See Original text in context

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␤»

From type/Complex

See Original text in context

method truncate(Complex:D: --> Complex:D)

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␤»