2 ms·
But what's the point? What is this useful for, or is it only academic?
by pzxc 16y ago
But what's the point? What is this useful for, or is it only academic?
- sp332 16y agoNegative 0 means that you have a negative value, but the value is too small to be represented with available precision. It's a way of noting the sign of the value even if the magnitude is unavailable. It could be useful if you're testing edge cases, or if you're looking for signs of an infinity (or negative infinity) in your program.
- jckarter 16y agoThere are lots of edge cases where the sign of zero affects computation. In floating-point, zero values represent not only the exact value zero but the result of an underflowed computation too small to represent as a non-zero floating point value, so retaining the sign is often important to at least keep such computations on the correct side of a branch cut or limit. For example: x/+0 = +infinity x/-0 = -infinity sqrt(+0) = 0 sqrt(-0) = nan log(+0) = -infinity log(-0) = nan