c2.js icon indicating copy to clipboard operation
c2.js copied to clipboard

Add mod() function

Open thonkinator opened this issue 2 years ago • 0 comments

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

thonkinator avatar Oct 22 '22 18:10 thonkinator