4 ms·
There's nothing wrong with relying on floating point to be "exact". That is, correctly rounded. As exact as it can be.
by gliptic 11y ago
There's nothing wrong with relying on floating point to be "exact". That is, correctly rounded. As exact as it can be.
- TillE 11y agoYes, but if you care about reading in exact numbers from text, floating point is usually not the right tool for the job.
- pcwalton 11y agoIt's perfectly fine as long as you know the rules. Virtually all JavaScript code is heavily reliant on exact answers from floating point (since floating point is all you have) and it continues to work. :)
- im3w1l 11y agoThey are heavily reliant on exact answers for the subset of small integers. But not that edges cases are handled 100% correct. Denormals, trigs of very large number, parsing of numbers with lots of significant figures. It could lead to degraded precision for mathematical calculations with lots of steps, but that should be a problem for only a small minority of js code.