Why are floating point numbers printed so differently?
It’s kind of a common knowledge that (most) floating point numbers are not stored precisely (when IEEE-754 format is used). So one shouldn’t do this:
It’s kind of a common knowledge that (most) floating point numbers are not stored precisely (when IEEE-754 format is used). So one shouldn’t do this:
I need to encode and decode IEEE 754 floats and doubles from binary in node.js to parse a network protocol.
>>> float(str(0.65000000000000002)) 0.65000000000000002 >>> float(str(0.47000000000000003)) 0.46999999999999997 ??? What is going on here? How do I convert 0.47000000000000003 to string and the resultant value back to float? I am using Python 2.5.4 on Windows. Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the … Read more
I know that most decimals don’t have an exact floating point representation (Is floating point math broken?).