Hacker News new | past | comments | ask | show | jobs | submit login

IEEE 754 defines an exact binary result for the addition of any two floats.

That this bit-identical result is not the same operation as addition of real numbers is irrelevant, because floats aren't reals.

f1 + f2 is not an estimation. Even treating it as an approximation will get you into trouble. It's not that either, it's a floating-point result, and algorithms making heavy use of floating point had better understand precisely what f1 + f2 is going to give you if they want to obtain maximum precision and accuracy.




Cool, so next time I have numbers that aren't reals to perform math on, I can use floats.


Or if you have numbers that aren't integers to perform math on, you can use integers.

It's not a new problem, and it isn't specific to floats. Computers do discrete math. Always have, always will.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: