News for hackers. Stuff that matters.
Re:Testing for -0 (negative zero) in JavaScript by jckarter on Wednesday February 16, 2011 @11:56PM (#2229825)
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

There are no comments on this comment yet.