LearnFrenzy
Sign in Take a free test

Variables and Data Types · Variables and Data Types MCQ · Question 15

Why is 0.1 + 0.2 not exactly 0.3? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 15 Back to Exercise

Why does 0.1 + 0.2 == 0.3 give False?

  • A Floats are stored as binary fractions, and 0.1, 0.2 and 0.3 cannot be represented exactly Correct
  • B Python adds floats incorrectly
  • C == cannot compare floats
  • D The result is an int
Correct Answer: Option A

The sum is 0.30000000000000004. Compare with math.isclose() or use decimal.Decimal for exact decimal values.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links