Last active
October 17, 2017 17:31
-
-
Save smcveigh-phunware/e5136ad7289183663acee047a312bdf7 to your computer and use it in GitHub Desktop.
2's compliment
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def twos(x:int) -> int: | |
assert x in range(256), "x is not an unsigned byte" | |
return x-256 if x > 0x7F else x | |
repr(list(map(twos, range(256)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment