c2.js
c2.js copied to clipboard
Add mod() function
Adds modulo function which behaves correctly with negative numbers.
JavaScript's default %
operator behaves differently than generally expected:
console.log(-1 % 10);
// Logs -1, but in other languages it typically logs 9
This is just a fix for that:
console.log(c2.mod(-1 % 10));
// Logs 9