# How do I calculate with decimals?

Adds, subtracts, multiplies, or divides two decimals exactly, shows the working, and rounds the answer to any number of decimal places.

- Page: https://www.acalculator.org/math/decimal-calculator
- JSON spec: https://www.acalculator.org/math/decimal-calculator.json
- Version: a31773148820

## Default answer

Example with the default inputs (First number 12.5, Operation +, Second number 3.75, Round to (decimal places) 2): 12.5 + 3.75 = 16.25.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | First number | A decimal number such as 12.5, -0.75 or 1,234.56. |
| op | Operation | Add, subtract, multiply, or divide the first number by the second. |
| b | Second number | A decimal number such as 3.75, -2 or 0.005. |
| dp | Round to (decimal places) | How many decimal places the rounded answer keeps, from 0 to 20. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| result | Answer | The exact answer: every digit when it ends, or the repeating digits marked with a bar. |
| rounded | Rounded | The answer rounded to the chosen number of decimal places; halves round away from zero. |
| fraction | As a fraction | The exact answer as a fraction in lowest terms. |
| steps | Working | How the answer is found by hand, one step at a time. |
| problem | Problem | The two numbers and the operation, written out in full. |

## Method

Add or subtract: write both numbers with the same number of decimal places and add the whole numbers. Multiply: multiply without the points; the product has as many decimal places as both numbers together. Divide: move both points right until both are whole, then divide.

## Assumptions

- Each number is read exactly as typed; there is no rounding in the answer.
- A quotient that does not end is written with a bar over the repeating digits (3.3̅ = 3.333…), or with its first 60 decimal places and "…" if no block repeats by then.
- The rounded answer keeps exactly the chosen number of decimal places; halves round away from zero.
- Dividing by 0 has no answer.

## Worked examples

1. a = 12.5, op = +, b = 3.75, dp = 1 gives result = 16.25, rounded = 16.3, fraction = 65/4, steps = Line up the decimal points with 2 decimal places each: 12.50 and 3.75; Add as whole numbers: 1250 + 375 = 1625; Put the decimal point back 2 places from the right: 16.25. Source: Method from OpenStax Prealgebra 2e, section 5.2: https://openstax.org/books/prealgebra-2e/pages/5-2-decimal-operations.
2. a = 0.1, op = +, b = 0.2 gives result = 0.3, fraction = 3/10.
3. a = 2.5, op = *, b = 0.04 gives result = 0.1, steps = Multiply without the decimal points: 25 × 4 = 100; 1 + 2 = 3 decimal places, so the product is 0.100 = 0.1.
4. a = 7.5, op = /, b = 0.25 gives result = 30, steps = Move both decimal points 2 places to the right: 750 ÷ 25; Divide: 750 ÷ 25 = 30.
5. a = 1, op = /, b = 0.3, dp = 4 gives result = 3.3̅, rounded = 3.3333, fraction = 10/3.
6. a = 5.2, op = -, b = 8.75 gives result = -3.55, steps = Line up the decimal points with 2 decimal places each: 5.20 and 8.75; Subtract as whole numbers: 520 − 875 = -355; Put the decimal point back 2 places from the right: -3.55.
7. a = -1.5, op = *, b = -0.3 gives result = 0.45, problem = -1.5 × (-0.3).

## FAQ

### How do I add or subtract decimals?

Line up the decimal points, filling empty places with zeros, then add or subtract as whole numbers and put the point back. 12.5 + 3.75: write 12.50 + 3.75, add 1250 + 375 = 1625, and put the point back two places from the right: 16.25.

### How do I multiply decimals?

Multiply the numbers as if there were no decimal points, then count the decimal places in both numbers together; the product has that many. 2.5 × 0.04: 25 × 4 = 100, and 1 + 2 = 3 places gives 0.100, which is 0.1.

### How do I divide decimals?

Move the decimal point of both numbers the same number of places to the right until the divisor is a whole number, then divide. 7.5 ÷ 0.25 is the same as 750 ÷ 25 = 30.

### Why does 0.1 + 0.2 give 0.3 here but 0.30000000000000004 in some programs?

Many programs store numbers in binary, where 0.1 and 0.2 cannot be written exactly, so a tiny error appears. This calculator keeps every digit you type as an exact decimal, so 0.1 + 0.2 is exactly 0.3.

### What does the bar over the digits mean?

A division can give a decimal that never ends. The bar marks the digits that repeat: 1 ÷ 0.3 = 3.3̅, which means 3.333… with the 3 repeating forever.

### How does the rounding work?

Pick how many decimal places to keep. The rounded answer writes all of them (16.25 to 3 places is 16.250). A value exactly halfway rounds away from zero: 16.25 to 1 place is 16.3, and −16.25 is −16.3.

### Can I type negative numbers or big numbers?

Yes. Type a minus sign for a negative number (−0.75), commas between thousands (1,234.56) if you like, or an exponent such as 2.5e-3 for 0.0025. There is no limit on the number of digits beyond the 60-character box.

## Sources

- OpenStax, Prealgebra 2e, section 5.2 Decimal Operations (add, subtract, multiply, and divide decimals): https://openstax.org/books/prealgebra-2e/pages/5-2-decimal-operations
- OpenStax, Prealgebra 2e, section 5.3 Decimals and Fractions (repeating decimals): https://openstax.org/books/prealgebra-2e/pages/5-3-decimals-and-fractions
