Binary Number System: Representations | |
IEEE 32-Bit Floating Point Format - EXAMPLE 2 The previous example was a little simplistic because the fractional portion of the number was a sum of powers of 1/2. This means that the binary representation will be an exact representation of the decimal value. Often, though, this is not possible. Consider, for example, the decimal value 42.42 expressed in IEEE Float. 1. Convert to binary: First convert the integer portion to an unsigned binary integer:
Next convert the fractional portion. This involves a technique which is the
inverse of that for the integer portion. Begin with the value to be represented:
then successively multiply by 2. The integer portion of each result is used to
create the binary fraction, the fractional portion of each result is used in the
next step. Repeat until the result is 0 or the number of bits allowed is
exceeded. Example:
0.42 x 2 = 0.84 0.84 x 2 = 1.68 0.68 x 2 = 1.36 0.36 x 2 = 0.72 0.72 x 2 = 1.44 0.44 x 2 = 0.88 0.88 x 2 = 1.76 0.76 x 2 = 1.52 0.52 x 2 = 1.04 0.04 x 2 = 0.08 0.08 x 2 = 0.16 0.16 x 2 = 0.32 0.32 x 2 = 0.64 0.64 x 2 = 1.28 0.28 x 2 = 0.56 0.56 x 2 = 1.12 0.12 x 2 = 0.24 0.24 x 2 = 0.48 0.48 x 2 = 0.96 0.96 x 2 = 1.92 0.92 x 2 = 1.84 <--- repeats here 0.84 x 2 = 1.68 0.68 x 2 = 1.36 Assembling the bits we have:
Note that the first few 1's are most significant:
Now we have:
2. Convert to normalized binary scientific notation:
3. Determine s, e and f:
4. Assemble the 32 bits:s = 0 e = 5 e+127 = 5 + 127 = 132 = 100001002 f = 010100110101110000101002 (note that some bits are dropped off the right) 5. Convert to hex:s e+127 1.fffffffffffffffffffffff 0 10000100 01010011010111000010100 01000010001010011010111000010100 0100 0010 0010 1001 1010 1110 0001 0100 4229AE14 Homework |