Skip to main content

Decimal.remainder

remainderthat

Group: Operators
Aliases: modulo, modulus

Documentation

Computes the remainder when dividing this by that.

Arguments to remainder will undergo automatic conversions such that you need not convert other numeric types to Decimal manually.

Arguments

  • that: The number to divide this by.

Examples

Computing the remainder when dividing 10 by 3 (which is 1).

      remainder = Decimal.new 10 . remainder 3
# => 1

Computing the remainder of a negative number.

      remainder = Decimal.new -5 . remainder 3
# => -2

Remarks

Negative Arguments

When the first argument to remainder is negative, the result will also be negative.