3 ms·
> Slightly off topic but why did we end up with floats as the standard? Because fixed point leads to catastrophic loss of precision way more often. For exampl
by Someone 4y ago
> Slightly off topic but why did we end up with floats as the standard?
Because fixed point leads to catastrophic loss of precision way more often.
For example, if you compute the product of two 16:16 fixed point values that both are around 1000, you like want to store the result in a 20:12 or 21:13 fixed point value.
If, on the other hand, both are about 0,001, the result best fits a 12:20 or 13:21 fixed point value.
You find that kind of issue with every operation. Want to sum a hundred numbers? Depending on their values, you may want to have up to 7 or 8 more digits before the decimal point in the result.
Want to compute sin or cos? A 16:16 fixed point results wastes half the storage. You probably want to return a 1:31 fixed point value.
So, what to do if you want to write a general-purpose library? Provide multiple functions for multiplying fixed width numbers?
Returning a pair (int, place of radix point) probably is the best you can do, and that is what IEEE floating point is.