8 ms·
There 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 o
by jckarter 16y ago
There 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