Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Created April 24, 2012 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meeDamian/2477707 to your computer and use it in GitHub Desktop.
Save meeDamian/2477707 to your computer and use it in GitHub Desktop.
[ JS | fix ] Negative Modulo Fix
/*
* By default JS returns invalid modulo values for negative numbers,
* below line fixes this, by overriding default js mod function
*/
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