Convert the following decimal numbers to IEEE single-precision format. Give the results as eight hexadecimal digits.
a. 10
b. 5/6
c. -10/15
d. 0.75
Convert the following decimal numbers to IEEE single-precision format.
Give the results as eight hexadecimal digits.
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:
a. 10
The general representation formula is:
(-1)^s * (1+mantissa) * 2^(Exponent – 127)
Sign
bit Exponent Mantissa
1 10000010 01000000000000000000000
(0)^1 2^3 1 + 1/4
1 * 8 * 1.25 = 10
BIN: 0100 0001 0010 0000 0000 0000 0000 0000
HEX: 0x 41200000
b. 5/6 = 0.833333333
Sign
bit Exponent Mantissa
0 01111110 10101010101010101010101
(-1)^0 2^(-1) 1 + 1/2+1/8 + 1/32 + 1/128 +..
1 * 0.5 * 1.6666 = 0.8333333
BIN: 0011 1111 0101 0101 0101 0101 0101 0101
HEX: 0x3f555555
c. -10/15=0.6666666666
bit Exponent Mantissa
1 01111110 01010101010101010101010
(-1)^1 2^(-1) 1 + 1/4+1/16 + 1/64 + 1/256 +..
-1*0.5*1.33333 = 0.6666666
BIN: 1011 1111 0010 1010 1010 1010 1010 1010
HEX: 0xbf2aaaaa
d. 0.75
bit Exponent Mantissa
1 01111110 10000000000000000000000
(-1)^0 2^(-1) 1 + 1/2
1*0.5*1.5 = 0.75
BIN: 0011 1111 0100 0000 0000 0000 0000 0000
HEX: 0x3f400000
Comments
Leave a comment