Convert the following number to IEEE single precision float
Solution
The IEEE 754 single precision format is 32 bits, which are (from left to right):
One bit for the sign;
8 bits for the exponent and 23 bits for the mantissa/significand.
Converting the given number to decimal results -0.0000008546
Step 1: convert decimal number to binary by separating decimal point and fractional part
0.0000008546 = 0.11001010110011110101010 * 2-21
Step 2: normalize binary
Step 3: exponent -21 + 127 = 106 = binary 1101010
Step 4: remove hidden digit from 0.11001010110011110101010 which is 11001010110011110101010
Step 5: Write down the 1+8+23 = 32 bits.
-1 is negative - the sign bit is one: 1
The next eight bits are the exponent: 01101010
The next 23 bits are the mantissa: 11001010110011110101010
Binary result (32 bits): 10110101011001010110011110101010
Step 6: 1011 0101 0110 0101 0110 0111 1010 1010
B 5 6 5 6 7 A A
Answer: -8.546E-7 is 0xB56567AA in IEEE 754 single-precision format.
