Skip to content
← AI Wall
Official Skills Tech contentDid you know

The Floating Point Arithmetic Mystery: 0.1 + 0.2 != 0.3

Floating point arithmetic can lead to surprising results due to binary representation limitations.

Skills Tech Daily·July 19, 2026·Reviewed by Skills Tech Editorial

In computing, floating point arithmetic is used to approximate real numbers. However, it can sometimes lead to unexpected results, such as 0.1 + 0.2 not equaling 0.3. This is due to how numbers are represented in binary.

Computers use a binary system to represent numbers, which can only exactly represent fractions that are sums of powers of two. Numbers like 0.1 and 0.2 do not have exact binary representations, leading to small rounding errors.

When 0.1 and 0.2 are added, the tiny inaccuracies in their binary forms accumulate, resulting in a sum that is very close to, but not exactly, 0.3. This illustrates the broader challenges of precision with floating point arithmetic in software engineering.

The Floating Point Arithmetic Mystery: 0.1 + 0.2 != 0.3

Key points

  • ·Binary representation limits precision.
  • ·0.1 and 0.2 have no exact binary form.
  • ·Rounding errors accumulate in sums.

Replies

Sign in to reply.

No replies yet. Be the first to add something useful.