0

I have a question about the floating point. the question: Given a floating-point format with one sign bit, 8 exponent bits, and 23 fraction bits. what is the largest odd float number that can be represented exactly?

I'm not sure but I think it = 2^(mantissa bits + 1) - 1

hope someone can help me with the question.

Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
  • 1
    That looks about right. Should be easy to check. – Rudy Velthuis May 13 '18 at 15:28
  • Does this answer your question? [Largest odd integer that can be represented as a float](https://stackoverflow.com/questions/52267201/largest-odd-integer-that-can-be-represented-as-a-float) – Steve Summit Mar 17 '23 at 17:44

1 Answers1

0

To clarify terminology, the number of bits in the significand of the IEEE-754 basic 32-bit binary floating-point format is 24. 23 is the number of bits in the field used for encoding most of the significand. An additional bit is encoded via the exponent field. The number of bits in the mathematical significand is 24.

Thus the largest value the significand can have, when scaled so that its low bit represents 20, is 224−1. This is of course odd. If the exponent is set to scale the number higher, then it has no bit that represents an odd value, so the number represented is necessarily even. If the exponent is set to scale the number lower, then it cannot be as large as 224−1. Therefore, 224−1 is the largest odd integer representable in IEEE-754 basic 32-bit binary floating-point format.

In general, if a floating-point format uses base b, has p base-b digits, and has a maximum exponent of E such that the maximum representable value is (bp−1) × bE, then:

  • If b is odd, the largest odd integer representable is (bp−2) × bE.
  • If b is even, the largest odd integer representable is (bp−1) × b0 = bp−1.

(Subject to normal characteristics, such as E is positive and p is at least 1.)

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312