4 ms·
If you're developing floating point code, you're in for a huge surprise, eventually. What happens for example when you subtract two close numbers with an error
by vardump 5y ago
If you're developing floating point code, you're in for a huge surprise, eventually. What happens for example when you subtract two close numbers with an error like this? There are a lot of mechanisms for small errors to become significant.
Many of us have had their attitudes readjusted by a bug where these "insignificant" errors became anything but.
We're often wrong in ways we can't imagine, so it is wise to remain humble and try to strive for correctness over our potentially misguided ideas how things work.
For example, you'd better still have multiple layers of security even though we've already made some other layer "impenetrable". And still check for those "impossible" error cases before they create nearly undebuggable issues.
- andi999 5y agoYes, one has to careful about floating point, but honestly the article is not about that. Actually it is more about something where you do not have to be careful.
- vardump 5y agoThe article explicitly says while you might get away with it with some luck due to characteristics of the real world data, you do have to be careful. From TFA: "Now, in the real world, you have programs that ingest untold amounts of data. They sum numbers, divide them, multiply them, do unspeakable things to them in the name of “big data”. Very few of the people who consider themselves C++ wizards, or F# philosophers, or C# ninjas actually know that one needs to pay attention to how you torture the data. Otherwise, by the time you add, divide, multiply, subtract, and raise to the nth power you might be reporting mush and not data. One saving grace of the real world is the fact that a given variable is unlikely to contain values with such an extreme range. On the other hand, in the real world, one hardly ever works with just a single variable, and one can hardly every verify the results of individual summations independently. Anyway, the point of this post was not to make a grand statement, but to illustrate with a simple example that when using floating point, the way numbers are added up, and divided, matters."