To convert the floating point into decimal, we have 3 elements in a 32-bit floating point representation:
Sign (MSB)
Exponent (8 bits after MSB)
Mantissa (Remaining 23 bits)
Sign bit is the first bit of the binary representation. ‘1’ implies negative number and ‘0’ implies positive number. Sign bit=1
Exponent is decided by the next 8 bits of binary representation.
Hence the exponent of 2 will be 3. i.e 23=8.
127 is the unique number for 32 bit floating point representation. It is known as bias. It is determined by 2k-1-1 where ‘k’ is the number of bits in exponent field.
Thus bias = 127 for 32 bit. (28-1-1 = 128-1=127)
127+3=130 i.e. 10000010 in binary representation.
Mantissa: 12 in binary = 1100
Move the binary point so that there is only one bit from the left. Adjust the exponent of 2 so that the value does not change. This is normalizing the number.
1.100 x 23
10000000000000000000000
Thus the floating point representation of -12 is
1 10000010 10000000000000000000000