Last active
August 29, 2015 14:01
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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