Skip to content

Instantly share code, notes, and snippets.

@banjeremy
Created July 1, 2017 14:12
Show Gist options
  • Save banjeremy/94f4a4d00cbb79a5477f5f5f60a61372 to your computer and use it in GitHub Desktop.
Save banjeremy/94f4a4d00cbb79a5477f5f5f60a61372 to your computer and use it in GitHub Desktop.
proper modulo on negative numbers
def mod(m: Int, n: Int) = ((m % n) + n) % n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment