next up previous contents
Next: Denormals and Zeroes Up: Floating-Point Formats Previous: Classification of Formats   Contents

5.2 Normal Encodings

The exponent field of a normal encoding can be neither all 0's nor all 1's, and for an explicit format, the integer bit must be 1:

Definition 5.2.1   (normp) An encoding $ x$ for a format $ F$ is normal iff the following conditions hold:

(a) $ 0 < \mathit{expf}(x, F) < 2^{\mathit{expw}(F)}-1$ ;

(b) If $ F$ is explicit, then $ x[\mathit{prec}(F)-1] = 1$ .

Definition 5.2.2   (unsupp) An encoding $ x$ for a format $ F$ is unsupported iff the following conditions hold:

(a) $ F$ is explicit ;

(a) $ \mathit{expf}(x, F) > 0$ ;

(b) $ x[\mathit{prec}(F)-1] = 0$ .

Let $ x$ be a normal encoding for a format with $ \mathit{prec}(F) = p$ and $ \mathit{expw}(F) = q$ . The significand field $ \mathit{sigf}(x, F)$ is interpreted as a $ p$ -exact value in the interval $ [1,2)$ , i.e., with an implied a radix point following the leading bit, which is 1, either explicitly or implicitly. The value encoded by $ x$ is the signed product of this value and a power of 2 determined by the exponent field. Since it is desirable for the range of exponents to be centered at 0, this field is interpreted with a bias of $ 2^{q-1}-1$ , i.e., the value of the exponent represented is

$\displaystyle 2^{\mbox{\scriptsize {\it expf}}(x,F) - (2^{q-1}-1)},
$

which lies in the range

$\displaystyle 2^{q-1}-1 \leq \mathit{expf}(x,F) - (2^{q-1}-1) \leq 2^{q-1}.
$

Thus, the decoding function is defined as follows.

Definition 5.2.3   (bias) The exponent bias of a format $ F$ is $ \mathit{bias}(F) = 2^{\mathit{expw}(F)-1}-1$ .

Definition 5.2.4   (ndecode) If $ x$ is a normal encoding for a format $ F$ , then

$\displaystyle \mathit{ndecode}(x,F)
= (-1)^{\mathit{sgnf}(x,F)}\left(1+2^{1-\mathit{prec}(F)}\mathit{manf}(x,F)\right)2^{\mathit{expf}(x,F)-\mathit{bias}(F)}.
$

The following is trivial consequence of Definition 5.2.4.

Lemma 5.2.1   (sgn-ndecode, expo-ndecode, sig-ndecode) Let $ x$ be a normal encoding for a format $ F$ and let $ \hat{x} = ndecode(x,F)$ . then

(a) $ \mathit{sgn}(\hat{x}) = (-1)^{\mathit{sgnf}(x,F)}$ ;

(b) $ \mathit{expo}(\hat{x}) = \mathit{expf}(x,F)-bias(F)$ ;

(c) $ \mathit{sig}(\hat{x}) = 1 + 2^{1-\mathit{prec}(F)}\mathit{manf}(x,F)$ .

Definition 5.2.5   (nrepp) Let $ F$ be a format and let $ r \in \mathbb{Q}$ . Then $ r$ is representable as a normal in $ F$ iff the following conditions hold:

(a) $ r \neq 0$ ;

(b) $ 0 < \mathit{expo}(r)+\mathit{bias}(F) < 2^{\mathit{expw}(F)}-1$ ;

(c) $ r$ is $ \mathit{prec}(F)$ -exact.

The normal encoding of a representable value is derived as follows.

Definition 5.2.6   (nencode) If $ r$ is representable as a normal in $ F$ , then

$\displaystyle \mathit{nencode}(r,F) = \{1\verb!'!s, \mathit{expw}(F)\verb!'!(\m...
...t{bias}(F)),
\mathit{sigw}(F)\verb!'!2^{\mathit{prec}(F)-1}\mathit{sig}(r)\},
$

where $ s = \left\{\begin{array}{ll}
0 & \mbox{if $r > 0$}\\
1 & \mbox{if $r < 0$.}
\end{array}\right.$

The next two lemmas establish an inverse relation between the encoding and decoding functions, from which it follows that the numbers that admit normal encodings are precisely those that satify Definition 5.2.5.

  (nrepp-ndecode, nencode-ndecode) If $ x$ is a normal encoding for a format $ F$ , then $ \mathit{ndecode}(x, F)$ is representable as a normal in $ F$ and

$\displaystyle \mathit{nencode}(\mathit{ndecode}(x, F), F) = x.
$

PROOF: Let $ p = \mathit{prec}(F)$ , $ q = \mathit{expw}(F)$ , $ B = \mathit{bias}(F)$ , and $ \hat{x} = \mathit{ndecode}(x, F)$ . It is clear from Definition 5.2.4 that $ \hat{x} \neq 0$ . By Lemma 5.2.1,

$\displaystyle expo(\hat{x})+B = \mathit{expf}(x,F)$

is a $ q$ -bit vector, and

$\displaystyle 2^{p-1}\mathit{sig}(\hat{x}) = 2^{p-1}(1+2^{1-p}\mathit{sigf}(x,F)) = 2^{p-1}+\mathit{sigf}(x,F) \in \mathbb{Z},
$

i.e., $ \hat{x}$ is $ p$ -exact. Thus, $ \hat{x}$ is representable as a normal in $ F$ .

It also clear from Definition 5.2.4 that $ \mathit{sgnf}(x,F) = \left\{\begin{array}{ll}
0 & \mbox{if $\hat{x} > 0$}\\
1 & \mbox{if $\hat{x} < 0$.}
\end{array}\right.$
Suppose $ F$ is implicit. Then by Definitions 5.2.6 and 5.1.4 and Lemmas 2.4.9 and 2.2.5,

$\displaystyle \mathit{nencode}(\hat{x},F)$ $\displaystyle =$ $\displaystyle \{\mathit{sgnf}(x,F), q\verb!'!(\mathit{expo}(\hat{x})+B)\},
(p-1)\verb!'!(2^{p-1}(\mathit{sig}(\hat{x})-1))\}$  
  $\displaystyle =$ $\displaystyle \{\mathit{sgnf}(x,F), q\verb!'!\mathit{expf}(x,F), (p-1)\verb!'!\mathit{sigf}(x,p)\}$  
  $\displaystyle =$ $\displaystyle \{x[p+q-1], x[p+q-2:p-1], x[p-2:0]\}$  
  $\displaystyle =$ $\displaystyle x[p+q-1:0]$  
  $\displaystyle =$ $\displaystyle x.$  

The explicit case is similar. 

  (normp-nencode, ndecode-nencode) If $ r$ is representable as a normal in a format $ F$ , then $ \mathit{nencode}(r,F)$ is a normal encoding for $ F$ and

$\displaystyle \mathit{ndecode}(\mathit{nencode}(r,F), F) = r.
$

PROOF: We give the proof for the implicit case; the explicit case is similar.

Let $ p = \mathit{prec}(F)$ , $ q = \mathit{expw}(F)$ , $ B = \mathit{bias}(F)$ , and $ x = \mathit{nencode}(r,F)$ . By Lemma 2.4.1, $ x$ is a $ (p+q)$ -bit vector and by Lemma 2.4.7,

$\displaystyle \mathit{sgnf}(x,F) = x[p+q-1] = \left\{\begin{array}{ll}
0 & \mbox{if $r > 0$}\\
1 & \mbox{if $r < 0$,}
\end{array}\right.$

$\displaystyle \mathit{expf}(x,F) = x[p+q-2:p-1] = (\mathit{expo}(r)+B)[q-1:0],
$

and

$\displaystyle \mathit{sigf}(x,F) = x[p-2:0] = (2^{p-1}(\mathit{sig}(r)-1))[p-2:0].
$

Since $ \mathit{expo}(r)+B$ is a $ q$ -bit vector,

$\displaystyle (\mathit{expo}(r)+\mathit{bias}(F))[q-1:0] = \mathit{expo}(r)+B
$

by Lemma 2.2.5.

Since $ r$ is $ p$ -exact,

$\displaystyle 2^{p-1}(\mathit{sig}(r)-1) = 2^{p-1}sig(r)-2^{p-1} \in \mathbb{Z}
$

and by Lemma 4.1.7, $ 2^{p-1}(\mathit{sig}(r)-1) < 2^{p-1}$ , which implies

$\displaystyle (2^{p-1}(\mathit{sig}(r)-1))[p-2:0] = 2^{p-1}(\mathit{sig}(r)-1).
$

Finally, according to Definition 5.2.4,
$\displaystyle \mathit{ndecode}(x,F)$ $\displaystyle =$ $\displaystyle (-1)^{\mathit{sgnf}(x,F)}(2^{p-1}+\mathit{sigf}(x,p))2^{\mathit{expf}(x,F)+1-p-\mathit{bias}(F)}$  
  $\displaystyle =$ $\displaystyle \mathit{sgn}(r)2^{p-1}\mathit{sig}(r)2^{\mathit{expo}(r)+B+1-p-B}$  
  $\displaystyle =$ $\displaystyle \mathit{sgn}(r)\mathit{sig}(r)2^{\mathit{expo}(r)}$  
  $\displaystyle =$ $\displaystyle r.$  

We shall have occasion to refer to the smallest and largest positive numbers that admit normal representations.

Definition 5.2.7   (spn) For any format $ F$ , $ \mathit{spn}(F)= 2^{1-bias(F)}$ .

  (positive-spn, nrepp-spn, spn-smallest)
If $ F$ is a format, then

(a) $ \mathit{spn}(F) > 0$ ;

(b) $ \mathit{spn}(F)$ is representable as a normal in $ F$ ;

(c) $ r$ is representable as a normal in $ F$ , then $ \vert r\vert \geq \mathit{spn}(F)$ .

PROOF: It is clear that $ \mathit{spn}(F)$ is positive and satisfies Definition 5.2.5. Moreover, if $ r>0$ and $ r$ is representable as a normal in $ F$ , then since $ \mathit{expo}(r) > -\mathit{bias}(F)$ , $ r \geq 2^{1-\mathit{bias}(F)}$ by Lemma 4.1.2


Definition 5.2.8   (lpn) For any format $ F$ , $ \mathit{lpn}(F)= 2^{2^{\mathit{expw}(F)-1-bias(F)}}(2 - 2^{1-\mathit{prec}(F)})$ .

  (positive-lpn, nrepp-lpn, lpn-largest)
If $ F$ is a format, then

(a) $ \mathit{lpn}(F) > 0$ ;

(b) $ \mathit{lpn}(F)$ is representable as a normal in $ F$ ;

(c) If $ r$ is representable as a normal in $ F$ , then $ r \leq \mathit{lpn}(F)$ .

PROOF: It is clear that $ \mathit{lpn}(F)$ is positive and satisfies Definition 5.2.5. Let $ p = \mathit{prec}(F)$ and $ q = \mathit{expw}(F)$ . If $ r$ is representable as a normal in $ F$ , then by Definition 5.2.5, $ \mathit{expo}(r) \leq 2^q-1-\mathit{bias}(F)$ and $ r$ is $ p$ -exact. Thus, $ r < 2^{\mathit{expo}(r)+1} \leq 2^{2^q-\mathit{bias}(F)}$ and by Lemma 4.2.21,

$\displaystyle r \leq \mathit{fp}^-(2^{2^q-\mathit{bias}(q)}, p) = \mathit{lpn}(F).$


next up previous contents
Next: Denormals and Zeroes Up: Floating-Point Formats Previous: Classification of Formats   Contents
david.m.russinoff 2015-05-29