1. To convert the floating point into decimal, we have 3 elements in a 32-bit floating point representation:
i) Sign
ii) Exponent
iii) Mantissa
There are 2 exponent bits in 8-bit representation and 8 exponent bits in 32-bit representation.
Thus
bias = 3 for 8 bit conversion (22-1 -1 = 4-1 = 3)
bias = 127 for 32 bit conversion. (28-1 -1 = 128-1 = 127)
Example: 01000001110100000000000000000000
10000011 = (131)2
131-127 = 4
Hence the exponent of 2 will be 4 i.e. 24 = 16.
Example:
01000001110100000000000000000000
The fractional part of mantissa is given by:
1*(1/2) + 0*(1/4) + 1*(1/8) + 0*(1/16) +……… = 0.625
Thus the mantissa will be 1 + 0.625 = 1.625
The decimal number hence given as: Sign*Exponent*Mantissa = (-1)*(16)*(1.625) = -26
2. To convert the decimal into floating point, we have 3 elements in a 32-bit floating point representation:
i) Sign (MSB)
ii) Exponent (8 bits after MSB)
iii) Mantissa (Remaining 23 bits)
Thus the floating point representation of -17 is 1 10000011 0001000000000000000000
Thus bias = 127 for 32 bit. (28-1 -1 = 128-1 = 127)
Now, 127 + 4 = 131 i.e. 10000011 in binary representation.
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.0001 x 24. Now, consider the fractional part and represented as 23 bits by adding zeros.
00010000000000000000000
32 docs|15 tests
|
1. What are number representations in computer arithmetic? |
2. What is the difference between fixed-point and floating-point representations? |
3. How does a computer perform arithmetic operations on fixed-point numbers? |
4. What are the advantages of using floating-point representations in computer arithmetic? |
5. What are the limitations of floating-point representations in computer arithmetic? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|