Decimal Encoding Specification, version 1.01
Copyright (c) IBM Corporation, 2009. All rights reserved. ©
 7 Apr 2009 
[previous  contents  next]

This section, which is not part of the encoding specification, describes
how E_{max} and E_{min} (the maximum and minimum
exponents available in a format) and bias (the amount to be subtracted
from the encoded exponent to form the exponent’s value) are calculated.
Except for the calculation of E_{limit}, these calculations are
general for any format where the coefficient and exponent are both
integers.

Let p
be the precision (total length of the coefficient) of
a format, in digits.

Let E_{max}
be the maximum positive exponent for a value in
a format, as defined in IEEE 854.
That is, the largest possible number is
(10^{p}–1) /
(10^{(p–1)}) ×
10^{Emax}
For example, if p=7 this is 9.999999 ×
10^{Emax}.

The exponent needed for the largest possible number is
E_{max}–(p–1) (because, for example, the
largest coefficient when p=7 is 9999999, and this only needs to
be multiplied by
10^{Emax} / 10^{(p–1)} to give the
largest possible number).

E_{min}=–E_{max} (as defined by IEEE 854 for base
10 numbers).
That is, the smallest normal number is 10^{Emin}.
The exponent needed for this number is E_{min} (its
coefficient will be 1).

The number of exponents, E_{normals},
used for the normal
numbers is therefore 2 × E_{max} – p + 2.
(The values –E_{max} through –1, 0, and 1 through
E_{max}–(p–1).)

Let E_{tiny}
be the exponent of the smallest possible (tiniest,
nonzero) subnormal number when expressed as a power of ten. This is
E_{min} – (p–1).
For example. if p=7 again, the smallest subnormal is 0.000001
× 10^{Emin},
which is 10^{Etiny}.
The number of exponents needed for the subnormal numbers,
E_{subnormals}, is therefore E_{min} –
E_{tiny}, which is p – 1.

Let E_{range}
be the number of exponents needed for both the
normal and the subnormal numbers; that is, E_{normals} +
E_{subnormals}.
This is (2 × E_{max} + 1).

Place E_{tiny} so its encoded exponent
(the exponent with bias added) is 0 (the encoded exponent cannot be
less than 0, and we want an allzeros number to be valid – hence
an encoded exponent of 0 must be valid).

Let E_{limit} be the maximum encoded exponent value available.
For the formats in the specification, this is
3 × 2^{ecbits} – 1, where
ecbits is the length of the exponent continuation in bits
(for example, E_{limit} is 191 for the 32bit format).

Then, the number of exponent values available is E_{limit} + 1,
which is 3 × 2^{ecbits}.

Now, to maximize E_{max}, E_{range} = E_{limit} + 1
That is, 2 × E_{max} + 1 =
3 × 2^{ecbits}.

Hence: E_{max} =
(3 × 2^{ecbits} – 1)/2 =
E_{limit}/2
Note that the divisions by 2 must be truncating integer division.

If E_{limit} is odd (always the case in these encodings), one
value of exponent would be unused. To make full use of the values
available, E_{min} remains as the value just calculated,
negated, and E_{max} is increased by one.^{[1]}
Hence: E_{min} = –E_{limit}/2
and: E_{max} =
E_{limit}/2 + 1
(where the divisions by 2 are truncating integer division).
 And: bias = –E_{tiny} =
–E_{min} + p – 1
For example, let E_{limit} = 191 and p = 7 (the 32bit
format).
Then:
E_{max} = 191/2 + 1 = 96
E_{min} = –95
E_{tiny} = –101
bias = 101
The parameters and derived values for all three formats are as follows:
Format
 ecbits
 E_{limit}
 p
 E_{max}
 E_{min}
 bias

32bit
 6
 191
 7
 96
 –95
 101

64bit
 8
 767
 16
 384
 –383
 398

128bit
 12
 12287
 34
 6144
 –6143
 6176
 
Note that it is also possible to consider the coefficients in these
formats to have a decimal point after the first digit (instead of after
the last digit). With this view, the bit patterns for the layouts are
identical, but the bias would be decreased by p–1,
resulting in the same value for a given number.
Footnotes:
[1] 
As decided by the IEEE 754r committee at its January 2003 meeting.

[previous  contents  next]