method
divmod
ruby latest stable - Class:
BigDecimal
divmod(p1)public
Divides by the specified value, and returns the quotient and modulus as BigDecimal numbers. The quotient is rounded towards negative infinity.
For example:
require 'bigdecimal' a = BigDecimal("42") b = BigDecimal("9") q, m = a.divmod(b) c = q * b + m a == c #=> true
The quotient q is (a/b).floor, and the modulus is the amount that must be added to q * b to get a.