3 ms·
Hotter take: Floats are bad and shouldn't be used. It's clear that even experienced programmers do NOT understand how they work, how they don't work, and the p
by pierat 3y ago
Hotter take: Floats are bad and shouldn't be used.
It's clear that even experienced programmers do NOT understand how they work, how they don't work, and the pile of edge cases.
Use something saner, like binary coded decimal, larger types, and use floats as a last and very approximate resort.
- zokier 3y agoAs if even experienced programmers understand anything about numerics, regardless of number format used. And all numbers have pitfalls, reals are not representable on computers, not all reals are even computable. Floats at least are well-documented and predictable, and there is 30+ years of literature on how to do error analysis for them.
- aragilar 3y agoNo, it's clear people don't know how to compute (because they're not taught how to). The vast majority of issues that people encounter with floating point aren't floating point issues, it's "how do I perform this calculation without infinite space and time", and these issues occur whether or not you do it by hand, or use a machine to do it for you. This issue becomes really obvious when you teach early-undergrad science labs, because people conflate the number of decimal points used with the number of significant figures used. This can be seen between the definition of the speed of light (which has in effect infinite precision because we defined what it is) as 299792458 m/s, vs the gravitational constant with 0.000 000 000 066 74 m^3 /kg /s^2 which is generally regarded as the most inaccurate and hardest to measure physical constant (usually G * M can be measured more accurately, so you'd rather use that).