3. Assume that a floating-point number system has base 2, word length 32 bits, mantissa length 24 bits, and does rounding. Assume also that the first bit is implicit. Represent the numbers 1/2, 2/3 and 3/5 as floating-point numbers in this system. (Hint: For less confusion, you might want to write out all 25 binary digits.)
2/3 = 0.666666.....
In binary equivalent number is 0.101010101010101010101010 (in 24 bits)
= 1.01010101010101010101010 x 2-1
Since mantissa must be represent as 1.bbbbbbbbbbbb...
i.e.1 in integer part, remaining part at fraction part, and adjust exponent in such a way that the value remains same.
Therefore mantissa = 01010101010101010101010
For 8 bits exponent, 127 bias is used.
so, add the exponent -1 added with bias 127, that is 126. [ -1 + 127 = 126 ]
Now, binary representation of 126 is 0111 1110 (in 8 bits)
For positive number sign bit is 0
Therefore, 2/3 can be represented in 32 bit floating point number system has base 2 is:
sign bit | exponent | mantissa |
0 | 01111110 | 01010101010101010101010 |
3/5 = 0.6
In binary equivalent number is 0.100110011001100110011001 (in 24 bits)
= 1.00110011001100110011001 x 2-1
Since mantissa must be represent as 1.bbbbbbbbbbbb...
i.e.1 in integer part, remaining part at fraction part, and adjust exponent in such a way that the value remains same.
Therefore mantissa = 00110011001100110011001
For 8 bits exponent, 127 bias is used.
so, add the exponent -1 added with bias 127, that is 126 [ -1 + 127 = 126 ]
Now, binary representation of 126 is 0111 1110
For positive number sign bit is 0
Therefore, 3/5 can be represented in 32 bit floating point number system has base 2 is:
sign bit | exponent | mantissa |
0 | 01111110 | 00110011001100110011001 |
1/2 = 0.5
In binary equivalent number is 0.100000000000000000000000 (in 24 bits)
= 1.00000000000000000000000 x 2-1
Since mantissa must be represent as 1.bbbbbbbbbbbb...
i.e.1 in integer part, remaining part at fraction part, and adjust exponent in such a way that the value remains same.
Therefore mantissa = 00000000000000000000000
For 8 bits exponent, 127 bias is used.
so, add the exponent -1 added with bias 127, that is 126 [ -1 + 127 = 126 ]
Now, binary representation of 126 is 0111 1110 (in 8 bits)
For positive number sign bit is 0
Therefore, 1/2 can be represented in 32 bit floating point number system has base 2 is:
sign bit | exponent | mantissa |
0 | 01111110 | 00000000000000000000000 |
N.B The given hint more confusion, "all 25 binary digits" means what?
In 32 bits representation, 1 bit sign, 8 bits exponent and 24 bits mantissa (including 1 in integer part) is used here.
If you want 24 bits mantissa (excluding 1 in integer part) then please share with me. I'll modify the answer.
Then also mention the number of exponent bits (I think that should be 7 bits, and 1 sign bit)
Get Answers For Free
Most questions answered within 1 hours.