next up previous contents
Next: 5.5  Rebiasing Exponents Up: 5  Floating-Point Formats Previous: 5.3  Denormals and Zeroes     Contents

5.4  Infinities and NaNs

The upper extreme value $ 2^\mathit{expw}(F)-1$ of the exponent field is reserved for encoding non-numerical entities. According to Definition 5.2.2, an encoding for an explicit formal with exponent field $ 2^\mathit{expw}(F)-1$ is unsupported if its integer bit is 0. In all other cases an encoding with this exponent field is an infinity is its significand field is 0, and a NaN (Not a Number) otherwise. A NaN is further classified as an SNaN (signaling NaN) or a QNaN according the the MSB of its mantissa field:

Definition 5.4.1   (infp, nanp, snanp, qnanp) Let $ x$ be an encoding for a format $ F$ with $ \mathit{expf}(x, F) = 2^\mathit{expw}(F)-1$ and assume that if $ F$ is explicit, then $ x[\mathit{prec}(F)-1] = 1$ .

(a) $ x$ is an infinity for $ F$ iff $ \mathit{expf}(x,F) = \mathit{manf}(x,F) = 0$ ;

(b) $ x$ is a NaN for $ F$ iff $ \mathit{manf}(x,F) \neq 0$ ;

(c) $ x$ is an SNaN for $ F$ iff $ x$ is a NaN and $ x[\mathit{prec}(F)-2] = 0$ ;

(c) $ x$ is a QNaN for $ F$ iff $ x$ is a NaN and $ x[\mathit{prec}(F)-2] = 1$ .

This function constructs an infinity with a given sign:

Definition 5.4.2   (iencode) Let $ F$ be a format and let $ s \in \{0, 1\}$ . Then

$\displaystyle \mathit{iencode}(s, p, q) = \left\{\begin{array}{ll}
\{1\verb!'!s...
..., 1\verb!'!1, (p-1)\verb!'!0\} & \mbox{if $F$ is explicit.}\end{array}\right.
$

The following function converts an SNaN to a QNaN:

Definition 5.4.3   (qnanize) If $ x$ is a NaN encoding for a format $ F$ , then

$\displaystyle \mathit{qnanize}(x, F) = x \;\verb!\vert!\; 2^{\mathit{prec}(F)-2}.
$

The following encoding, known as the real indefinite QNaN, has special significance in the handling of floating-point exceptions:

Definition 5.4.4   (indef) For any encoding $ F$ ,

$\displaystyle \mathit{indef}(F) = \left\{\begin{array}{ll}
\{\{(\mathit{expw}(F...
...\mathit{prec}(F)-2)\verb!'!0\} & \mbox{if $F$ is explicit.}\end{array}\right.
$

Infinities and NaNs will be discussed further in Part III.


next up previous contents
Next: 5.5  Rebiasing Exponents Up: 5  Floating-Point Formats Previous: 5.3  Denormals and Zeroes     Contents
david.m.russinoff 2015-08-11