Last active
December 9, 2017 20:18
-
-
Save paulhayes/c47930054e82dd5b12965e9064835c3f to your computer and use it in GitHub Desktop.
Using modulo operating to wrap values in both positive and negative directions
This file contains hidden or 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
| Number.prototype.wrap = function(len){return ((this.valueOf()%len)+len)%len; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment