Why 0.1 + 0.2 Is Not 0.3

Type 0.1 + 0.2 into most programming languages and you get 0.30000000000000004. This is not a bug, and it is worth understanding - especially since this calculator deliberately hides it.

Last updated: August 2026 · Written and verified by Akash Pandey

The cause: base 10 versus base 2

You already accept that some fractions cannot be written exactly as decimals. One third is 0.333… forever; no finite number of decimal digits will ever pin it down. The reason is that 3 is not a factor of 10, the base we are writing in.

Computers store numbers in base 2, where the only clean fractions are those whose denominators are powers of two - halves, quarters, eighths. One tenth is not among them. In binary, 0.1 is 0.0001100110011… repeating forever, exactly as one third repeats in decimal.

A double-precision number has 53 bits of significand, so that infinite expansion gets cut off. What is actually stored when you type 0.1 is:

0.1000000000000000055511151231257827021181583404541015625

Add two of these slightly-wrong values together and the errors do not cancel - they compound just enough to push the sum past the nearest representable value to 0.3. Hence 0.30000000000000004.

What this calculator does about it

Results are rounded to 12 significant digits before being displayed. That threshold is chosen deliberately: a double carries roughly 15–17 significant decimal digits of precision, so rounding at 12 discards the last few digits - which is exactly where the accumulated noise lives - while keeping every digit that is genuinely reliable.

You typeThe raw double isThe calculator shows
0.1 + 0.20.300000000000000040.3
1.1 × 33.30000000000000033.3
0.3 − 0.10.199999999999999980.2
4.35 × 100434.99999999999994435
1 ÷ 30.33333333333333330.333333333333
The rounding hides accumulated error without inventing precision that is not there.

Note the last row. One third genuinely has no exact representation, so the calculator shows twelve threes and stops. It is not pretending the answer is exact - it is showing every digit it can stand behind.

Where the display switches to scientific notation

Two other boundaries follow from the same reasoning.

  • Integers above 2⁵³ − 1 = 9,007,199,254,740,991. Below this every integer is exactly representable, so all its digits are shown. Above it, doubles can no longer represent every integer - the gaps grow to 2, then 4, then 8 - so printing a full decimal expansion would be claiming precision that does not exist. Scientific notation is the honest alternative.
  • Values below 10⁻⁶. A number like 0.0000000234 is easier to read, and less error-prone, as 2.34e-8.

This is why 19! appears in scientific notation while 18! is shown in full: 18! is about 6.4 × 10¹⁵, just under the integer boundary, and 19! is about 1.2 × 10¹⁷, comfortably over it.

When the difference actually matters

  • Money. Never store currency as a floating-point value. Use integer minor units - pence, cents - or a decimal type. Accumulated fractions of a penny are a real class of accounting bug.
  • Equality tests. In code, if (a === b) on computed floats is unreliable. Compare within a tolerance instead.
  • Long chains of operations. Error accumulates. Where a formula can be rearranged to subtract two nearly equal numbers, that subtraction will lose the most precision - the classic example being the quadratic formula when b² is much larger than 4ac.

For everyday arithmetic, homework and engineering estimates, none of this matters - twelve reliable significant digits is far more than any physical measurement justifies. It matters when you are writing software, and it matters when a result looks strange and you need to know whether you have found a real error or an artefact of binary representation.

Frequently Asked Questions

Why does 0.1 + 0.2 equal 0.30000000000000004?

Because 0.1 and 0.2 cannot be stored exactly in binary. Each is rounded to the nearest representable value, and the two small errors compound so that the sum lands just past 0.3.

Is this a bug in my calculator or programming language?

No. It is the IEEE 754 floating-point standard, which virtually all hardware and software implements. Tools that appear not to have the problem are rounding the display.

How does this calculator avoid showing it?

It rounds every result to 12 significant digits before display. A double carries about 15–17, so the last few - where the noise sits - are discarded while all the reliable digits are kept.

Does that mean results are inaccurate?

No. The rounding removes error rather than adding it. Twelve significant digits is well beyond the precision of any real-world measurement.

How can I get exact fraction answers instead?

Use the fraction calculator, which keeps numerators and denominators as whole numbers throughout and never rounds.

Why do very large numbers switch to scientific notation?

Above 2⁵³ − 1 a double cannot represent every integer, so printing a full decimal expansion would imply digits that are not real. Scientific notation only claims the precision that actually exists.