Java Reference
In-Depth Information
Table 3-11. A Binary Representation of a Quiet NaN
Number
Sign
Exponent
Significand
Signaling NaN
s
11111111
0bbbbbbbbbbbbbbbbbbbbbb
Ieee defines 2 24 - 2 distinct NaNs for the single-precision format and 2 53 - 2 distinct NaNs for the double-precision
format. however, Java has only one NaN for the float data type and one NaN for the double data type. Java always uses
a quiet NaN .
Tip
Denormals
When the biased exponent is 0 and the significand is non-zero, it denotes a denormalized number. Table 3-12 shows
the bits pattern to represent denormalized numbers in the single-precision format.
Table 3-12. The Bits Pattern for a Denormalized Single-Precision Floating-Point Number
Sign
Exponent
Significand
s
000000000
fffffffffffffffffffffff
In Table 3-12 , s denotes a sign bit, which can be 0 for a positive number and 1 for a negative number. The exponent
bits are all zeros. At least one of the bits in the significand is denoted 1. The decimal value of the denormalized number
is computed as shown:
(-1) s * 0.fffffffffffffffffffffff * 2 -126
Suppose you want to store a number 0.25 x 2 -128 in the single-precision format. If you write this number in
normalized form after converting 0.25 in binary, it will be 1.0 x 2 -130 . However, the minimum exponent allowed
for single-precision format is -126. Therefore, this number cannot be stored in normalized form in single-precision
format. The exponent is kept as -126 and the binary point is shifted to the left, resulting in denormalized form as
0.0001 x 2 -126 . The number is stored as shown in Table 3-13 .
Table 3-13. Bits Pattern for a Denormalized Number 1.0 * 2 -130
Number
Sign
Exponent
Significand
0.0001 x 2 -126
0
00000000
00010000000000000000000
It seems that for the number 0.0001 x 2 -126 , the biased exponent should be computed as -126 + 127 = 1 and the
exponent bits should be 00000001. However, this is not true. For denormalized numbers, the exponent is stored as all
0 bits; when reading it back, it is interpreted as -126. This is so because you need to distinguish between normalized
and denormalized numbers when reading back floating-point numbers, and for all denormalized numbers, there is
no leading 1-bit in their significands. The denormalized numbers fill the gap around zero on the number line, which
would have been there if you had stored only normalized numbers.
 
Search WWH ::




Custom Search