aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math.js
blob: c745cdc26f2ffdac73f3c58147e036c89ed97cf8 (plain)
1
2
3
4
5
6
7
8
/**
 * Modulo that acts well with negative numbers.
 * @param {number} dividend the number to divide
 * @param {number} divisor the divisor to calculate the remainder
 */
export const modulo = function modulo (dividend, divisor) {
  return ((dividend % divisor) + divisor) % divisor
};