Decimal Calculator

Enter two decimal numbers, pick an operation, and get the exact answer — computed with true decimal arithmetic, so 0.1 + 0.2 comes out as 0.3, not 0.30000000000000004. You also get the result rounded to 1, 2, and 3 decimal places.

Put this calculator on your website — free

Copy one snippet and give your visitors a working Decimal Calculator.

Why your computer thinks 0.1 + 0.2 isn't 0.3

Type 0.1 + 0.2 into most programming languages, spreadsheets, or online calculators and you'll get 0.30000000000000004. That's not a bug in the software so much as a consequence of how computers store numbers: in binary floating point, where every number must be built from halves, quarters, eighths, and so on. One tenth in binary is 0.0001100110011… repeating forever — just like 1/3 never terminates in decimal — so the computer stores the closest binary fraction it can, which is very slightly off. Add two slightly-off numbers and the error peeks out in the last digit. The same glitch makes 0.3 − 0.1 come out as 0.19999999999999998 and 0.3 ÷ 0.1 as 2.9999999999999996.

This calculator sidesteps the whole mess by working the way you were taught in school: it counts in whole-number units of the smallest decimal place. 0.1 + 0.2 becomes 1 tenth + 2 tenths = 3 tenths = 0.3, exactly.

The place-value rules

Add / subtract: line up the decimal points, then work digit by digit
Multiply: ignore the points, multiply, then count total decimal places back in
Divide: shift both points right until the divisor is whole, then long-divide

Each digit's position sets its value: tens, ones, tenths, hundredths, thousandths. Adding and subtracting only works between digits of the same place value — that's all "line up the points" means. For multiplication, the decimal places of the factors add together: a 3-place number times a 1-place number gives a 4-place answer.

Worked examples

Addition: 0.1 + 0.2 = 1 tenth + 2 tenths = 0.3 — exactly, with no trailing …00004.

Multiplication: 1.005 × 2.3 → multiply 1005 × 23 = 23,115, then count 3 + 1 = 4 places back: 2.3115.

Division: 0.3 ÷ 0.1 → shift both one place: 3 ÷ 1 = 3. (Binary floating point famously answers 2.9999999999999996 here.)

When the digits never end

Exact arithmetic has one honest limit: some divisions have no exact decimal answer at all. 1 ÷ 3 = 0.333… repeats forever, and no calculator on earth can print it in full. A division terminates only when the divisor, reduced to lowest terms, is built purely from 2s and 5s — the prime factors of 10. That's why ÷4, ÷8, and ÷2.5 come out clean, while ÷3, ÷7, and ÷1.1 (which is 11/10) repeat. When that happens, this calculator shows the result rounded to 12 decimal places and tells you it did — which beats quietly pretending the number stopped there.

Frequently asked questions

Why does 0.1 + 0.2 equal 0.30000000000000004 on some calculators?

Most software stores numbers in binary floating point, and 0.1 and 0.2 have no exact binary representation — the computer stores the nearest binary fraction instead, and those tiny errors add up to 0.30000000000000004. This calculator works in whole-number units of the smallest decimal place (1 + 2 tenths = 3 tenths), so the answer is exactly 0.3.

How many decimal places should the answer have when multiplying decimals?

Add up the decimal places of the two factors: 1.005 (three places) × 2.3 (one place) has 3 + 1 = 4 places, giving 2.3115. Multiply as if there were no decimal points, then count that many places back from the right. Trailing zeros can then be dropped.

How do I add or subtract decimals by hand?

Line up the decimal points vertically, pad the shorter number with zeros so both have the same number of decimal places, then add or subtract like whole numbers. The decimal point in the answer sits directly below the ones above it.

How do I divide decimals by hand?

Shift both decimal points to the right by the same number of places until the divisor is a whole number — 4.5 ÷ 0.15 becomes 450 ÷ 15. Shifting both numbers equally doesn't change the answer, and dividing by a whole number is ordinary long division.

What is a repeating decimal and why does division cause them?

A repeating decimal never terminates, like 1 ÷ 3 = 0.333… A division terminates only when the divisor, in lowest terms, has no prime factors other than 2 and 5 — the factors of 10. Divide by 3, 7, or 11 and the digits cycle forever; this calculator shows such results rounded to 12 decimal places and says so.

Related calculators