Skip to content

Instantly share code, notes, and snippets.

@cawka
Created June 26, 2020 16:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cawka/d044df792ebf73e4de4cc9e782dd582f to your computer and use it in GitHub Desktop.
Save cawka/d044df792ebf73e4de4cc9e782dd582f to your computer and use it in GitHub Desktop.
b = 0
m_bits = 5
m_max = (1<<m_bits)
for i in range(0,256):
e = i >> m_bits
m = i & ((1<<m_bits) - 1)
if e == 0:
x = (0 + m / m_max) * pow(2, 1 + b)
else:
x = (1 + m / m_max) * pow(2, e + b)
print ("%d (e=%d, m=%d) = %f" % (i, e, m, x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment