The Art of Assembly Language

4.5 Special Floating-Point Values

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 implied bit) determines whether the value represents a quiet not-a-number (QNaN) or a signaling not-a-number (SNaN) (see Table 4-1). These not-a-number (NaN) results tell the system that some serious miscalculation has taken place and that the result of the calculation is completely undefined. QNaNs represent indeterminate results, while SNaNs specify that an invalid operation has taken place. Any calculation involving a NaN produces an NaN result, regardless of the values of any other operand(s). Note that the sign bit is irrelevant for NaNs. The binary representations of NaNs are shown in Table 4-1.

Table 4-1: Binary Representations for NaN

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 ( well-defined ) values found in Table 4-2.

Table 4-2: Operations Involving Infinity

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.

Категории