Skip to content

Instantly share code, notes, and snippets.

@jonathanstark
Created December 19, 2013 05:07
Show Gist options
  • Save jonathanstark/8034686 to your computer and use it in GitHub Desktop.
Save jonathanstark/8034686 to your computer and use it in GitHub Desktop.
Modulo bugfix for negative numbers
// Modulo bugfix for negative numbers
Number.prototype.mod = function(n) {
return ((this%n)+n)%n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment