mod
mod(
value,modulus):number
Defined in: packages/core/src/number/integer/mod.ts:17
Floored remainder — takes the sign of the divisor, so it pairs with
divFloor: a === divFloor(a, m) * m + mod(a, m).
This is what mod names in Knuth, Haskell, Lisp, Ada, Julia and Ruby, and
what Python’s % computes. It is not JavaScript’s %, which takes the sign
of the dividend: -7 % 2 is -1, while mod(-7, 2) is 1.
For a remainder that stays non-negative even when the modulus is negative, use modEuclid.
Parameters
Section titled “Parameters”number
The dividend, may be negative.
modulus
Section titled “modulus”number
The divisor, may be negative.
Returns
Section titled “Returns”number
value reduced into [0, modulus) for a positive modulus.
Throws
Section titled “Throws”When modulus is zero.