Reputation: 3175
Here's the number I'm working on
1 01110 001 = ____
1 sign bit, 5 exp bits, 3 fraction bits
bias = 15
Here's my current process, hopefully you can tell me where I'm missing something
01110 = 14
14 - 15 = -1
0.001 * 2^-1 = 0.0001
.0001 = 1/16
The sign bit is 1 so my result is -1/16, however the given answer is -9/16. Would anyone mind explaining where the extra 8 in the fraction is coming from?
Upvotes: 1
Views: 310
Reputation: 69
For normalized floating point representation, the Mantissa (fractional bits) = 1 + f. This is sometimes called an implied leading 1 representation. This is a trick for getting an additional bit of precision for free since we can always adjust the exponent E so that significant M is in the range 1<=M < 2 ...
You are almost correct but must take into consideration the implied 1. If it is denormalized (meaning the exponent bits are all 0s) you do not add an implied 1.
I would solve this problem as such...
1 01110 001
bias = 2^(k-1) -1 = 14
Exponent = e - bias
14 - 15 = -1
hope that helps!
Upvotes: 2
Reputation:
You seem to have the correct concept, including an understanding of the excess-N representation, but you're missing a crucial point.
The 3 bits used to encode the fractional part of the magnitude are 001
, but there is an implicit 1.
preceding the fraction bits, so the full magnitude is actually 1.001
, which can be represented as an improper fraction as 1+1/8 => 9/8
.
2^(-1)
is the same as 1/(2^1)
, or 1/2
.
9/8 * 1/2 = 9/16
. Take the sign bit into account, and you arrive at the answer -9/16
.
Upvotes: 2