Skip to content
instance method

Numeric#truncate

() -> ::Integer
(::Integer ndigits) -> (::Integer | ::Numeric)
truncate(digits = 0) → integer or float

Returns self truncated (toward zero) to a precision of digits decimal digits.

Numeric implements this by converting self to a Float and invoking Float#truncate.

See also #to_int #zero? #to_c also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0