Skip to content

Instantly share code, notes, and snippets.

@ayubmetah
Created January 20, 2021 21:48
Show Gist options
  • Save ayubmetah/96840d6baa4dee16fb4e7e61c1e87b8d to your computer and use it in GitHub Desktop.
Save ayubmetah/96840d6baa4dee16fb4e7e61c1e87b8d to your computer and use it in GitHub Desktop.
Converting in python
def toHex(dec):
digits = "0123456789ABCDEF"
x = (dec % 16)
rest = dec // 16
if (rest == 0):
return digits[x]
return toHex(rest) + digits[x]
# numbers = [0, 11, 16, 32, 33, 41, 45, 678, 574893]
# for x in numbers:
# print(x, toHex(x))
# for x in numbers:
# print(x, hex(x))
#numbers = [0, 11, 16, 32, 33, 41, 45, 678, 574893]
for x in range(200):
print(x, toHex(x), hex(x), chr(x),)
# for x in range(200):
# print(x, hex(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment