Skip to content

Instantly share code, notes, and snippets.

@mahenzon
Created July 17, 2018 11:02
Show Gist options
  • Save mahenzon/772e1ed2e64165b41c93c29dc78eb0c7 to your computer and use it in GitHub Desktop.
Save mahenzon/772e1ed2e64165b41c93c29dc78eb0c7 to your computer and use it in GitHub Desktop.
Convert from int to bcd format and counterwise with pure python
def bcd_to_int(n):
return int(('%x' % n), base=10)
def int_to_bcd(n):
return int(str(n), base=16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment