The value 512 is represented in hexadecimal as 200.
3. Write the hexadecimal number, 200, in floating-point representation. To do this,
move the decimal point all the way to the left, counting the number of positions that
you moved it. The number you moved it is the exponent:
4. Convert the fraction portion (.1) of the original number, 512.1 to hexadecimal:
.1 =
1
10
=
1.6
16
The numerator cannot be a fraction, so keep the 1 and convert the .6 portion again.
.6 =
6
10
=
9.6
16
Again, there cannot be fractions in the numerator, so keep the 9 and reconvert the .6
portion.
The .6 continues to repeat as 9.6 which means that you keep the 9 and reconvert. The
closest that .1 can be represented in hexadecimal is
.1 = .1999999 × 16
0
5. The exponent for the value is 3 (Step 2 above). To determine the actual exponent that
will be stored, take the exponent value and add the bias to it:
true exponent + bias = 3 + 40 = 43 (hexadecimal) = stored exponent
The final portion to be determined is the sign of the mantissa. By convention, the
sign bit for positive mantissas is 0, and the sign for negative mantissas is 1. This
information is stored in the first bit of the first byte. From the hexadecimal value in
Step 4, compute the decimal equivalent and write it in binary format. Add the sign
bit to the first position. The stored value now looks like this:
43 hexadecimal = (4 × 16
1
) + ( 3 × 16
0
) = 67 decimal = 0100 0003 binary
11000003 = 195 in d ecimal = C3 in hexadecimal
6. The final step is to put it all together:
4320019999999999 – floating point representation for 512.1
C320019999999999 – floating point representation for –512.1
Therefore, the decimal value 512.1 cannot be precisely represented in binary or
hexadecimal floating point notation. When the number 512.1 is converted, the result
is an infinitely repeating number. This is analogous to representing the fraction 1/3 in
decimal form.
The closest approximation is .33333333 with infinitely repeating ‘3s’.
This example shows how values that can be represented exactly in decimal notation
cannot always be represented precisely in floating-point notation. If a floating-point
value has a repeating pattern of numbers (like the above value has repeating ‘9s’), there
is a good chance that the value cannot be represented exactly.
Numerical Accuracy in SAS Software 71