|
|
|
|
|
by bicsi
1338 days ago
|
|
The story is much worse than what is presented in the article, especially when talking about floating point errors that add (or rather multiply) up. More often than not, the error is relative wrt the greatest magnitudes in the intermediary calculations. In essence, if you subtract two floating point numbers, you’re kinda screwed, because you cannot ever handle with good precision cases like A - B, where A and B are big enough numbers. Not to mention more complicated operations like trig functions. In my opinion, one should avoid floating point as much as possible. And not only when testing for equality (all comparisons suffer from this). Or, of course, ignore FPEs and proceed at your own risk. |
|
This is not a problem with floats. This is an inherent* result of the design constraints. You can not fix it and there are no alternatives without this flaw which offer any of the same benefits as floats.
Any operation between two floats is the floating point number which is closest to the result calculated as real numbers, that is the magic of floats.
Floating point numbers are a near magical type, which for many applications are not only a good choice, but the only one which makes any sense. It is near impossible to imagine modern engineering without them.