|
|
|
|
|
by harpiaharpyja
1936 days ago
|
|
Reading your comment gave me a realization that transformed my understanding of floats. What just clicked for me was that in any system where we use finite precision to store exponents, we can't actually have zero as a normal value... we'll always underflow the exponent before we get to actual mathematical zero. So +0/-0 is actually a convenient misnomer. They really are +/- epsilon. The only way to have zero is if it's some specially handled value like NaN. Which IEEE doesn't do and that's entirely understandable. Makes sense why you can never compare a subtraction of floats to zero (it's beyond just "rounding errors") and the existence of +0/-0 seems quite natural now. |
|
Wait what? Am I missing something? 0 is absolutely part of the IEEE 754 spec thanks to the existence of denormalized floating point numbers. So I would certainly call it a "specially handled value", in a sense. The existence of +/- 0 has more to do with the implementation of the leading sign bit.