问题
(Assume no bits are implied, there is no biasing, exponents use two’s complement notation, and exponents of all zeros and all ones are allowed.) I am trying to find the largest and smallest number that can be represented if the system is normalized. I thought that the largest number would be:
.1111 x 2^4 = 0 100 1111 = 15
and the smallest:
1.0 x 2^-4 = 0 000 0001 = 0.0625
But the answers that I saw were:
Largest: .1111 x 2^3 = 111.1 = 7.5
Smallest: 0.1 x 2^-4 = .00001 = 0.03125
I do not understand how either answer would even be possible in a 4-bit significand.
回答1:
There're a few things to decipher here.
Exponent: 3-bits, 2's complement, no bias. This means the exponent can represent values in the range
-4
(corresponding to100
) to3
(corresponding to011
).Normalized without implied bit: This means significand always starts with a
1
.
When you put these together, the maximum number you can write is:
0 011 1111 = 2^3 * (2^-1 + 2^-2 + 2^-3 + 2^-4) = 7.5
Since floating point values are symmetic around 0
, the minumum value you can write is -7.5
by flipping the sign bit above. But I guess your teacher is going for minumum strictly positive (i.e., non-zero) value. In that case, we pick the exponent to be as small as possible, and just keep the first bit of the significand to satisfy the normalized requirement. We get:
0 100 1000 = 2^-4 * 2^-1 = 2^-5 = 0.03125
Hope that makes sense!
来源:https://stackoverflow.com/questions/59914695/if-the-floating-point-number-storage-on-a-certain-system-has-a-sign-bit-a-3-bit