Signed zero

Negatively signed zero echoes the mathematical analysis concept of approaching 0 from below as a one-sided limit, which may be denoted by x → 0−, x → 0−, or x → ↑0.

The concept of negative zero also has some theoretical applications in statistical mechanics and other disciplines.

It is claimed that the inclusion of signed zero in IEEE 754 makes it much easier to achieve numerical accuracy in some critical problems,[1] in particular when computing with complex elementary functions.

Representations that allow negative zero can be a source of errors in programs, if software developers do not take into account that while the two zero representations behave as equal under numeric comparisons, they yield different results in some operations.

In a 1+7-bit sign-and-magnitude representation for integers, negative zero is represented by the bit string 10000000.

sign below shows the obtained floating-point results (it is not the usual equality operator).

The usual rule for signs is always followed when multiplying or dividing: There are special rules for adding or subtracting signed zero: Because of negative zero (and also when the rounding mode is upward or downward), the expressions −(x − y) and (−x) − (−y), for floating-point variables x and y, cannot be replaced by y − x.

Some other special rules: Division of a non-zero number by zero sets the divide by zero flag, and an operation producing a NaN sets the invalid operation flag.

In those languages, special programming tricks may be needed to distinguish the two values: Note: Casting to integral type will not always work, especially on two's complement systems.

However, some programming languages may provide alternative comparison operators that do distinguish the two zeros.

Negative zero by IEEE 754 representation in binary32