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