Skip to content

Instantly share code, notes, and snippets.

@Ekdohibs
Created September 10, 2017 14:48
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 Ekdohibs/870a2af8950f3147f4d912f59909d897 to your computer and use it in GitHub Desktop.
Save Ekdohibs/870a2af8950f3147f4d912f59909d897 to your computer and use it in GitHub Desktop.
>>> def pmod(a, b):
... if a >= 0:
... return a % b
... return b-((-a)%b)
...
>>> def tos(a,b):
... if a < b:
... return a
... return a-2*b
...
>>> for u in range(-2**24,2**24):
... assert (tos(pmod(u,4096), 2048) == tos(u&0xfff,2048))
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment