Convert the following IEEE single-precision floating point numbers from hex to decimal:
a. 42F48000
b. CAB00000
c. 00700000
d. 3ABC0000
42F48000 Hexadecimal representation
0100 0010 1111 1000 0000 0000 000 0000 Binary representation
0 10000101 1111000000000000000000
Sign bit: 0
Mantissa: 1111000000000000000000
Exponent: 10000101
The general representation formula is:
(-1)^s * (1+mantissa) * 2^(Exponent – 127)
Conversion:
The value of a IEEE-754 number is computed as:
The sign is stored in bit 32. The exponent can be computed from bits 24-31 by subtracting 127. The mantissa (also known as significand or fraction) is stored in bits 1-23. An invisible leading bit (i.e. it is not actually stored) with value 1.0 is placed in front, then bit 23 has a value of 1/2, bit 22 has value 1/4 etc. As a result, the mantissa has a value between 1.0 and 2:
Mantissa: 1 + 1/2 + 1/4 + 1/8 +1/16 = 1.9375
Exponent: 133 – 127 = 6 -> 2^6
Sign: -1^0 = 1
ANSWER:
1 x 64 x 1.9375= 124
CAB00000
1100 1010 1011 0000 0000 0000 000 0000 Binary representation
1 10010101 0110000000000000000000
Sign bit: 1
Mantissa: 0110000000000000000000
Exponent: 10010101
Mantissa: 1 + 1/4 + 1/8 = 1.375
Exponent: 149 – 127 = 22 -> 2^22
Sign: -1^0 = 1
ANSWER:
-1 x 4194304 x 1.375 = -5767168
00700000
0000 0000 0111 0000 0000 0000 000 0000 Binary representation
Sign bit: 0
Mantissa: 1110000000000000000000
Exponent: 00000000
Mantissa: 1 + 1/2 + 1/4 + 1/8 = 1.875
Exponent: 1 – 127 = -126 -> 2^(-126)
Sign: -1^0 = 1
ANSWER:
1 x 2^(-126) x 1.875= 1.028557556969…
3ABC0000
0011 1010 1011 1100 0000 0000 000 0000 Binary representation
Sign bit: 0
Mantissa: 0111100000000000000000
Exponent: 01110101
Mantissa: 1 + 1/4 + 1/8 + 1/16 +1/32= 1.46875
Exponent: 117 – 127 = -10 -> 2^(-10) = 1/1024
Sign: -1^0 = 1
ANSWER:
1 x 2^(-10) x 1.46875= 1.001434326171875
Comments
Leave a comment