End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Integer#/
self / numeric → numeric_result
numeric.c
View on GitHub ↗
VALUE
rb_int_div(VALUE x, VALUE y)
{
if (FIXNUM_P(x)) {
return fix_div(x, y);
}
else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_div(x, y);
}
return Qnil;
}
Performs division; for integer numeric, truncates the result to an integer:
4 / 3 # => 1 4 / -3 # => -2 -4 / 3 # => -2 -4 / -3 # => 1 For other +numeric+, returns non-integer result: 4 / 3.0 # => 1.3333333333333333 4 / Rational(3, 1) # => (4/3) 4 / Complex(3, 0) # => ((4/3)+0i)