11.001001000011111101101010100010001000 Arithmazium
Home

Special cases

This section discusses situations that fall outside the usual model of round a mathematical result to fit into the destination.

NaNs beget NaNs

Any arithmetic operation on a NaN produces a NaN result. Special accommodation may be made for aggregating functions like min or max, but they fall outside the scope of basic arithmetic.

Zero result

In signed-magnitude systems like IEEE 754, zero has an algebraic sign whose rules fall outside ordinary mathematics. As with the actual computation, we look to the most natural – or perhaps least surprising – answer.

When zero results from mul or div, its sign is just the exclusive-or of the operands' signs. neg flips zero's sign and abs gives zero positive sign. copysign does what it says. The first surprise is sqrt, which preserves the sign of a zero input.

The unobvious cases are add and sub. What is the sign of the result of 5.0 - 5.0? There is no mathematical choice. The 754 rule is based on the rounding mode. Deliver +0 when rounding to nearest, toward 0, or toward \( + \infty \), and deliver -0 when rounding toward \( - \infty \).

The cases +0 + +0 and +0 - -0 deliver +0 with no sign ambiguity. Similarly, the cases -0 + -0 and -0 - +0 deliver -0. The 754 rule applies to the other four cases +0 + -0, +0 - +0, -0 + +0, and -0 - -0.

Zero divided by zero

This operation produces a NaN. It's called Invalid in 754.

\( \lim_{x,y \rightarrow 0} x / y \) does not exist.

Zero times infinity

This operation produces a NaN. It's called Invalid in 754.

\( \lim_{x \rightarrow 0, y \rightarrow \infty} x \times y \) does not exist.

Nonzero divided by zero

This operation produces \( \infty \) with the exclusive-or of the operands' signs, provided the number system supports an infinity symbol, as 754 does.

\( \lim_{y \rightarrow 0} x / y = \pm\infty \) for \( x \neq 0 \).

Finite divided by infinity

This operation produces \( 0 \) with the exclusive-or of the operands' signs.

\( \lim_{y \rightarrow \infty } x / y = 0 \) for \( x \) finite.

Nonzero times infinity

This operation produces \( \infty \) with the exclusive-or of the operands' signs.

\( \lim_{y \rightarrow \infty } x \times y = \pm \infty \) for \( x \neq 0 \).

Home