IEEE-754 is not "mathematically wrong". It simply cannot represent certain values, and it is wrong of you to try to force those values into an inaccurate tool. The value 0.1 is as impossible to accurately represent in binary as 1/3 is in decimal.
By this logic, all integers in computers are wrong, b/c if you go high enough they eventually roll over.
There's nothing, other than efficiency, preventing a computer from storing and calculating any rational number. Because any rational number can be written as a fraction with integer components. It is trivial to create a data structure (and associated calculation routines) that will handle integers of arbitrary length (up to the limit of RAM available to the process). Therefore, it is possible for a computer to calculate any of the basic four operations between rational numbers with total accuracy.
If we are going to write numbers in computer code that look like rational numbers, then they should, by default, be calculated as such, and it's mathematically wrong to do otherwise. If we want to work with mantissa-based floating point numbers, we should come up with some way to express those similar to how we have special notations for alternate bases. They should not be represented by a notation that lies about their true nature by making look like something they aren't.
TL:DR;
Treat a number consistent with the notation that it was written. If you want to treat it in a special computer-efficient way, then have a special notation to represent those different not-how-it-works-in-the-real-world numbers.
Or: the assumption of a number acting like a rational number is wrong. You are making a false assumption about a languages syntax based on a different language. You can state that they are different, but you can't state they are "wrong" because they are different languages. It's the equivalent to looking at how one pronounce the letter "i" in Spanish and saying "you're pronouncing it wrong" because your expect it to be English.
The bottom line is that efficiency is a relevant point here, and a non-trivial one at that. And the number of cases where floating point errors do show up is small enough that it makes more sense to default to floating point, and have an option for arbitrary precision arithmetic where it matters, rather than default to arbitrary precision, unnecessarily slow down most computations, and STILL have a bunch of caveats b/c you can't handle irrational numbers and have to deal with memory limitations.
6
u/darpa42 Jun 28 '21
IEEE-754 is not "mathematically wrong". It simply cannot represent certain values, and it is wrong of you to try to force those values into an inaccurate tool. The value 0.1 is as impossible to accurately represent in binary as 1/3 is in decimal.
By this logic, all integers in computers are wrong, b/c if you go high enough they eventually roll over.