Created
September 10, 2017 14:48
-
-
Save Ekdohibs/870a2af8950f3147f4d912f59909d897 to your computer and use it in GitHub Desktop.
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
>>> 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