Cldr.Math.mod
You're seeing just the function
mod
, go back to Cldr.Math module for more information.
Specs
mod(number_or_decimal(), number_or_decimal()) :: number_or_decimal()
Calculates the modulo of a number (integer, float or Decimal).
Note that this function uses floored division
whereas the builtin rem
function uses truncated division
. See Decimal.rem/2
if you want a
truncated division
function for Decimals that will return the same value as
the BIF rem/2
but in Decimal form.
See Wikipedia for an explanation of the difference.
Examples
iex> Cldr.Math.mod(1234.0, 5)
4.0
iex> Cldr.Math.mod(Decimal.new("1234.456"), 5)
#Decimal<4.456>
iex> Cldr.Math.mod(Decimal.new("123.456"), Decimal.new("3.4"))
#Decimal<1.056>
iex> Cldr.Math.mod Decimal.new("123.456"), 3.4
#Decimal<1.056>