Skip to content

Instantly share code, notes, and snippets.

@JackMc
Last active August 29, 2015 14:01
Show Gist options
  • Save JackMc/a0b0f586fe386b78ea3d to your computer and use it in GitHub Desktop.
Save JackMc/a0b0f586fe386b78ea3d to your computer and use it in GitHub Desktop.
Add for the fractional part of an IEEE floating-point number from a list of bits (least to most significant)
def fractional_add(bits):
accum = 0
for i, bit in enumerate(reversed(bits)):
accum += 1/(2**(i+1))
return accum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment