End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Numeric#truncate
truncate(digits = 0) → integer or float
numeric.c
View on GitHub ↗
static VALUE
num_truncate(int argc, VALUE *argv, VALUE num)
{
return flo_truncate(argc, argv, rb_Float(num));
}
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.