Created
April 24, 2012 08:01
-
-
Save meeDamian/2477707 to your computer and use it in GitHub Desktop.
[ JS | fix ] Negative Modulo Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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