QuestenaПрактика, после которой понятно, что повторить
Вопрос 11

Why can a calculation with the float `0.1` show a tiny discrepancy from the expected decimal result?

  1. Python randomly changes the final decimal digit.
  2. Binary float cannot represent every decimal fraction exactly.Правильный ответ
  3. A float always performs integer division before storage.
  4. The value is exact, so any discrepancy must be a display bug.

Объяснение

A binary floating-point value usually stores the closest representable approximation to one tenth rather than that decimal fraction exactly. The discrepancy is therefore a representation effect, not evidence that integer division secretly occurred.

Продолжить работу с тестом

Начать тренировку
Вопрос 11: Why can a calculation with the float `0.1` show a tiny… · Python Fundamentals · Questena