Created
July 4, 2017 08:09
-
-
Save hamrammi/b4d873de255f30cd65bfdf2cd0498254 to your computer and use it in GitHub Desktop.
Convert number to hex representation
This file contains hidden or 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
# coding: utf-8 | |
def tohex(val, nbits=64): | |
return hex((val + (1 << nbits)) % (1 << nbits)) | |
packet3 = (0x55, 0x01, 0xfe, 0x00, 0x00, 0x00) | |
print tohex(~sum(packet3)) # 0xfffffffffffffeabL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment