Modulus function
JavaScript's % operator returns the remainder, not the modulus. This behave different from modulus for negative values: -4 % 3 === -1.
%
-4 % 3 === -1
Modulus of negative value
const n = mod(-4, 3)console.log(n); // 2
the modulus of n and m
n
m
Generated using TypeDoc
Modulus function
Remark
JavaScript's
%operator returns the remainder, not the modulus. This behave different from modulus for negative values:-4 % 3 === -1.Example
Modulus of negative value
Returns
the modulus of
nandm