Skip to content

Instantly share code, notes, and snippets.

@yoursunny
Forked from cawka/time_tlv.py
Created June 26, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoursunny/c1e0aef17c74a23d23b85fca01a95f85 to your computer and use it in GitHub Desktop.
Save yoursunny/c1e0aef17c74a23d23b85fca01a95f85 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