1.9: Inexact Numbers
( \newcommand{\kernel}{\mathrm{null}\,}\)
Example:
13=(−1)0×14×(1+13),
so that p=e−127=−2 and e=125=128−3, or in binary, e=01111101. How is f=1/3 represented in binary? To compute binary number, multiply successively by 2 as follows:
0.333…0.0.666…0.01.333…0.010.666…0.0101.333…0.0101 etc.
so that 1/3 exactly in binary is 0.010101… With only 23 bits to represent f, the number is inexact and we have
f=01010101010101010101011
where we have rounded to the nearest binary number (here, rounded up). The machine number 1/3 is then represented as
00111110101010101010101010101011
or in hex
Зeaaaaab.
Find smallest positive integer that is not exact in single pre- cision
Let N be the smallest positive integer that is not exact. Now, I claim that
N−2=223×1.11…1
and
N−1=224×1.00…0
The integer N would then require a one-bit in the 2−24 position, which is not available. Therefore, the smallest positive integer that is not exact is 224+1=16777217. In MATLAB, single (224) has the same value as single (224+1). Since single (224+1) is exactly halfway between the two consecutive machine numbers 224 and 224+2, MATLAB rounds to the number with a final zero-bit in f, which is 224.