Method: Integer#div
- Defined in:
- numeric.c
#div(numeric) ⇒ Integer
Performs integer division; returns the integer result of dividing self by numeric:
4.div(3) # => 1
4.div(-3) # => -2
-4.div(3) # => -2
-4.div(-3) # => 1
4.div(3.0) # => 1
4.div(Rational(3, 1)) # => 1
Raises an exception if numeric does not have method div.
4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 |
# File 'numeric.c', line 4319 VALUE rb_int_idiv(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_idiv(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_idiv(x, y); } return num_div(x, y); } |