I'm preparing for some exams and one of the ques开发者_StackOverflow中文版tions given in the past is to find the closest number to 1.7 given an imaginary floating point format that has a total of 8 bits (1 for sign, 3 for exponent, 4 for significand).
Anyway I put down 1.1011 since I can play with four significand digits and the 1 is implied by the IEEE standard. However, setting the exponent to 000 would make it a denormalised number. Does this mean the value 1.7 would be 1.1100 in floating point?
thx
The questioner posted an answer that was deleted by a moderator. I've flagged it for attention, but I'll add a few notes here as well.
The key is that IEEE-754-style floating-point formats store the exponent in a "biased" (also called "excess-n") integer format. With 3 exponent bits, the bias is 3, so the set of encodeable exponents is:
encoding meaning
000 exponent for zeros and denormals
001 2^-2
010 2^-1
011 2^0
100 2^1
101 2^2
110 2^3
111 exponent for infinities and NaNs
Thus, the questioners value 1.7 would have an exponent field of 3 (b011
), and a significand field of b1011
as he stated, which makes the full value b00111011
.
Oh I completely forgot about the exponent bias, if anyone is wondering the floating point numbre exponent would have a bias of 3 so having at as 3 would give me the 2^0
精彩评论