The IEEE floating-point format provides a special encoding for several special values. In this section we'll look these special values, their purpose and meaning, and their representation in the floating-point format.
Under normal circumstances, the exponent bits of a floating-point number do not contain all zeros or all ones. An exponent containing all one or zero bits indicates a special value.
If the exponent contains all ones and the mantissa is nonzero (discounting the implied bit), then the HO bit of the mantissa (again discounting the
|
NaN |
FP Format |
Value |
|---|---|---|
|
SNaN |
32 bits |
%s_11111111_0xxxx...xx (The value of s value is irrelevant - at least one of the x bits must be nonzero.) |
|
SNaN |
64 bits |
%s_1111111111_0xxxxx...x (The value of s is irrelevant - at least one of the x bits must be nonzero.) |
|
SNaN |
80 bits |
%s_1111111111_0xxxxx...x (The value of s is irrelevant - at least one of the x bits must be nonzero.) |
|
QNaN |
32 bits |
%s_11111111_1xxxx...xx (The value of s is irrelevant.) |
|
QNaN |
64 bits |
%s_1111111111_1xxxxx...x (The value of s is irrelevant.) |
|
QNaN |
80 bits |
%s_1111111111_1xxxxx...x (The value of s is irrelevant.) |
Two other special values are represented when the exponent contains all one bits, and the mantissa contains all zeros. In such a case, the sign bit determines whether the result is the representation for +
infinity
or
ˆ’
infinity
. Whenever a calculation involves infinity as one of the operands, the arithmetic operation will produce one of the (
|
Operation |
Result |
|---|---|
|
n / ±infinity |
|
|
±infinity — ±infinity |
±infinity |
|
±nonzero / 0 |
±infinity |
|
infinity + infinity |
infinity |
|
n + infinity |
infinity |
|
n ˆ’ infinity |
ˆ’ infinity |
|
±0 / ±0 |
NaN |
|
infinity ˆ’ infinity |
NaN |
|
±infinity / ±infinity |
NaN |
|
±infinity — 0 |
NaN |
Finally, if the exponent bits are all zero, the sign bit indicates which of the two special values, ˆ’ 0 or +0, the floating-point number represents. Because the floating-point format uses a one's complement notation, there are two separate representations for zero. Note that with respect to comparisons, arithmetic, and other operations, +0 is equal to ˆ’ 0.
The IEEE floating-point standard defines certain
Invalid operation
Division by zero
Numeric overflow
Numeric underflow
Of these, inexact result is the least serious, because most
floating calculations will produce an inexact result. A
denormalized operand also isn't too serious (though this exception
indicates that your calculation may be less accurate as a result of
less available precision). The other exceptions
How the computer system notifies your application of these
exceptions depends on the CPU/FPU, operating system, and
programming language, so we can't really go into how one might
handle these exceptions. Generally, though, you can use the
exception-handling facilities in your programming language to trap
these conditions as they occur in your particular environment. Note
that most computer systems require that you explicitly tell them to
generate a notification for these exceptional conditions;