ProgrammingHardProduct-company MCQ pattern

What is the largest float that is less than 1.0 in Python, as printed by repr?

  1. A. 0.9999999999999999
  2. B. 0.999999999999999
  3. C. 0.99999999999999
  4. D. 1.0

Correct answer: A. 0.9999999999999999

The largest double below 1.0 is 1 - 2**-53, and its shortest round-trip repr has 16 nines. Literals with 17 nines round to 1.0, so they are not below one.

More Python Programming questions

Exams that ask this topic