Search code examples
mathfloating-pointfractions

floating point numbers - closest number to 1.7


I'm preparing for some exams and one of the questions 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


Solution

  • 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.