Skip to content

Instantly share code, notes, and snippets.

@animeoakes
Created August 17, 2015 17:11
Show Gist options
  • Save animeoakes/4210aaf788bb26e6f5f5 to your computer and use it in GitHub Desktop.
Save animeoakes/4210aaf788bb26e6f5f5 to your computer and use it in GitHub Desktop.
/**
* Take the modulo of a number with *correct* behavior on negative numbers.
*/
function mod(left, right) {
return (left % right + right) % right
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment