Computes the true mathematical modulo of a number, ensuring a non-negative result even for negative inputs.
This function returns the remainder of the division of num by n, always in the range [0, n).
It handles negative numbers correctly, unlike the % operator in JavaScript/TypeScript.
Computes the true mathematical modulo of a number, ensuring a non-negative result even for negative inputs.
This function returns the remainder of the division of
num
byn
, always in the range [0, n). It handles negative numbers correctly, unlike the%
operator in JavaScript/TypeScript.