IEEE 754 Conversion (32-Bit Single Precision) Bit Fields
IEEE 754 Conversion (32-Bit Single Precision) Bit Fields
Bit Fields
Sign: 1 bit (31), 0=positive, 1=negative
Exponent: 8 bits (30-21), excess 127
Mantissa: 21 bits (20-0), normalized base 2 fraction
Worked Examples
• Bits = 43FC0000
• Binary = 0100 0011 1111 1100 0000 0000 0000 0000
• Sign = 0
• Exponent = 100 0011 1 = 1000 0111 = 128 + 7 = 135; 135 – 127 = 8
• Mantissa = 111 1100 0000 0000 0000 0000 = 1 + .5 + .25 + .125 + .0625 + .03125 = 1.96875
• Float = + 1.96875 X 28 = + 1.96875 X 256 = 504.0
Conversion #2: Float-to-Bits (the “harder” direction)
• Let f be the float value.
• Determine the largest power of two that is not greater than f, call it p
• f = f/2p X 2p
• m = f/2p, subtract 1 and convert remaining value to binary with each bit position a negative
power of two
• e = p, add 127 and convert to binary
• If f is negative, sign=1, else sign=0
Worked Examples
Exponent Decimal
2-1 = 1/2 0.5
2-2 = 1/4 0.25
2-3 = 1/8 0.125
2-4 = 1/16 0.0625
2-5 = 1/32 0.03125
2-6 = 1/64 0.015625
2-7 = 1/128 0.0078125
2-8 = 1/256 0.00390625
2-9 = 1/512 0.001953125
2-10 = 1/1024 0.0009765625
So mantissa = 001011100000000000000
Sign = 0
01011 = 0.34375
01011 = 2-2 + 2-4 + 2-5 = 0.25 + 0.0625 + 0.03125 = 0.34375
For worked example #2, rather than directly converting the decimal to binary, we could look up the
closest value in the table not greater than the decimal value.
Actual decimal value = 0.1796875
Closest value not greater than from table = 0.15625
Equivalent binary = 00101
Bits Decimal
00000 0.00000
00001 0.03125
00010 0.06250
00011 0.09375
00100 0.12500
00101 0.15625
00110 0.18750
00111 0.21875
01000 0.25000
01001 0.28125
01010 0.31250
01011 0.34375
01100 0.37500
01101 0.40625
01110 0.43750
01111 0.46875
10000 0.50000
10001 0.53125
10010 0.56250
10011 0.59375
10100 0.62500
10101 0.65625
10110 0.68750
10111 0.71875
11000 0.75000
11001 0.78125
11010 0.81250
11011 0.84375
11100 0.87500
11101 0.90625
11110 0.93750
11111 0.96875
Exercises