12.5 F l o ating-Point Numbers | 597
location. The name “floating-point” refers to the concept that the decimal point is allowed to
float (move to different positions as necessary). In our coding scheme, every number is stored
as four digits, with the leftmost digit being nonzero and the exponent adjusted accordingly.
Numbers in this form are said to benormalized. For example, the number 1,000,000 is stored as
and 0.1032 is stored as
Normalization provides the maximum precision possible.
In Java, values of type floatuse 32 bits with an approximate range of 3.4E+38 to 3.4E+38
with 6 significant digits. Values of type doubleuse 64 bits with an approximate range of
1.7E+308 to 1.7E+308 with 15 significant digits.
Model Numbers Any real number that can be represented exactly as a floating-point number
in the computer is called a model number. A real number whose value cannot be represented
exactly is approximated by the model number closest to it. In our system with four digits of
precision, 0.3021 is a model number. The values 0.3021409, 0.3021222, and 0.30209999999 are
examples of real numbers that are represented in the computer by the same model number.
The following table shows all of the model numbers for an even simpler floating-point sys-
tem that has one digit in the mantissa, no sign (all mantissas are positive or zero), and an
exponent that can be 1, 0, or 1.
0.0 10 ^1 0.0 100 0.0 10 ^1
0.1 10 ^1 0.1 100 0.1 10 ^1
0.2 10 ^1 0.2 100 0.2 10 ^1
0.3 10 ^1 0.3 100 0.3 10 ^1
0.4 10 ^1 0.4 100 0.4 10 ^1
0.5 10 ^1 0.5 100 0.5 10 ^1
0.6 10 ^1 0.6 100 0.6 10 ^1
0.7 10 ^1 0.7 100 0.7 10 ^1
0.8 10 ^1 0.8 100 0.8 10 ^1
0.9 10 ^1 0.9 100 0.9 10 ^1
The difference between a real number and the model number that represents it is a
form of representational error called rounding error. We can measure rounding error in two
++41 032
++31 000