3 / 6 · Basic
Rounding: ROUND and what the cell shows
A cell formatted to two decimals can show 1.65 while it stores 1.649175. Only ROUND changes the stored number.
Jump to the 10 practice questionsYou will learn
- Tell the shown value from the stored value
Before this: SUM, AVERAGE, COUNT, MIN and MAX
1Explain
"It says 1.65, so it is 1.65"
Many beginners hold one belief about spreadsheets without ever saying it: the number you see in a cell is the number in the cell. Take a sales tax of 8.25% on a price of 19.99. The tax is 19.99 × 0.0825 = 1.649175. Format the cell to two decimal places and it reads 1.65. It still holds 1.649175, and every formula that uses it works with that full value. With normal settings, formatting changes only what you see. ROUND creates a rounded result that later formulas can use.
2Problem
Shown 1.65, stored more
B2 holds 1.649175 formatted to show 1.65. What does =B2*100 return?
Hint
Formatting does not change the stored number.
Solution
Answer: 164.9175
The stored value is 1.649175, so multiplying by 100 gives 164.9175. Showing 1.65 changes neither that stored value nor the result.
3Explain
Three thirds
The belief breaks in totals. Put =1/3 in three cells and format them to two decimals, and each shows 0.33. Their SUM shows 1.00, because the stored values add to exactly 1. Someone adding the visible numbers by hand gets 0.99 and decides the sheet is broken. On invoices and pay slips, where every visible figure has to add up, the cure is to round the stored value itself, at the point where the money is calculated.
4Problem
The SUM of three thirds
Three cells each hold =1/3, shown as 0.33. What does their SUM show at two decimals?
Hint
The stored values add to exactly 1.
Solution
Answer: 1.00
The stored thirds add to exactly 1.
5Explore
Binary and 15 digits
There is a second, quieter reason the stored value can surprise you. Spreadsheets store numbers in binary, and many decimals, such as 0.1, have no exact binary form. Microsoft gives Excel 15 digits of precision, so after a long chain of arithmetic, tiny leftovers can appear far past the fifteenth digit. You usually can't see them. They are still part of the stored value, and a comparison with an exact figure can come out FALSE because of them.
JavaScript stores numbers in binary too, so 0.1 + 0.2 is a hair off 0.3. Rounding on purpose brings it back.
console.log(0.1 + 0.2);0.300000000000000046Explain
What ROUND does to the stored number
ROUND(number, digits) rounds to a given number of decimal places, and unlike formatting, it changes the stored value. Microsoft's examples: =ROUND(2.15, 1) is 2.2, =ROUND(2.149, 1) is 2.1, and =ROUND(23.7825, 2) is 23.78. A halfway digit rounds away from zero, so =ROUND(-1.475, 2) is −1.48. Google's help phrases it as up and down in terms of size, irrespective of sign. Digits of 0 round to a whole number. A negative value rounds to the left of the decimal point: =ROUND(626.3, -3) is 1000 and =ROUND(1.98, -1) is 0.
| Formula | Result |
|---|---|
| =ROUND(2.15, 1) | 2.2 |
| =ROUND(2.149, 1) | 2.1 |
| =ROUND(-1.475, 2) | −1.48 |
| =ROUND(21.5, -1) | 20 |
| =ROUND(626.3, -3) | 1000 |
| =ROUND(-50.55, -2) | −100 |
7Problem
=ROUND(2.15, 1)
What does =ROUND(2.15, 1) return?
Hint
A halfway 5 rounds up.
Solution
Answer: 2.2
The next digit is 5, so it rounds up: 2.2.
8Problem
=ROUND(2.149, 1)
What does =ROUND(2.149, 1) return?
Hint
Look only at the next digit, 4.
Solution
Answer: 2.1
Only the next digit, 4, matters: round down to 2.1.
9Problem
=ROUND(23.7825, 2)
What does =ROUND(23.7825, 2) return?
Hint
The third decimal is 2.
Solution
Answer: 23.78
The third decimal is 2, so the second stays 8.
10Explore
Math.round is not ROUND
Math.round sends halves upwards, so -2.5 becomes -2. ROUND sends them away from zero, -3: round the size, then put the sign back.
const x = -2.5;
console.log(Math.round(x));
console.log(Math.sign(x) * Math.round(Math.abs(x)));-2
-311Problem
A negative halfway
What does =ROUND(-1.475, 2) return?
Hint
Away from zero.
Solution
Answer: −1.48
Halfway rounds away from zero, so −1.475 becomes −1.48.
12Problem
Negative digits
What does =ROUND(626.3, -3) return?
Hint
-3 means the nearest thousand.
Solution
Answer: 1000
−3 rounds to thousands; 626.3 is nearer 1000 than 0.
13Problem
=ROUND(21.5, -1)
What does =ROUND(21.5, -1) return?
Hint
The nearest ten.
Solution
Answer: 20
−1 rounds to tens; 21.5 is nearer 20.
14Explain
Excel and Sheets differ
Here the programs part ways slightly. In Excel the second argument, num_digits, is required. In Google Sheets, places is optional and 0 by default, so =ROUND(2.5) gives 3 in Sheets while Excel asks you to finish the formula. Writing the digits every time works in both and reads more clearly. For rounding that always goes one way, both programs have ROUNDUP and ROUNDDOWN; the lab here uses ROUND only.
15Problem
=ROUND(2.5)
What does =ROUND(2.5) do?
Hint
One program makes the digits optional.
Solution
Answer: Google Sheets gives 3; Excel asks for the missing argument
Sheets: places is optional, 0 by default. Excel: num_digits is required.
16Explain
ROUND around a calculation
ROUND can wrap any calculation. =ROUND(SUM(B2:B9)/COUNT(B2:B9), 1) gives an average to one decimal place, and =ROUND(A2*1.1, 0) adds 10% to a price and rounds to the nearest whole unit. Read formulas like these from the inside out: the calculation first, then the rounding of its result.
17Problem
Where to round money
Where should money be rounded so that visible figures add up?
Hint
So that the visible figures add up.
Solution
Answer: Where each amount is calculated
Formatting changes the look only; ROUND at each step changes the stored values.
18Explore
Practice in the grid
To locate a rounding discrepancy, compare a result calculated from original values with one calculated from explicitly rounded inputs. If only the display is rounded, those are different calculations. Decide which quantity the task asks for before correcting the sheet. Increasing displayed decimal places can reveal hidden digits, but it is not a substitute for choosing where the calculation should round.
Drag to turn. Scroll or pinch to zoom.
19Practice
ROUND in JavaScript
Finish round(x, digits) so that it works like ROUND: halves go away from zero, and negative digits round to tens, hundreds or thousands.
-3
2.2
20
1000
-100function round(x, digits) {
const f = 10 ** digits;
return x;
}
console.log(round(-2.5, 0));
console.log(round(2.15, 1));
console.log(round(21.5, -1));
console.log(round(626.3, -3));
console.log(round(-50.55, -2));
Hint
Round the absolute value, then multiply by Math.sign(x).
A solution
function round(x, digits) {
const f = 10 ** digits;
return Math.sign(x) * Math.round(Math.abs(x) * f) / f;
}
console.log(round(-2.5, 0));
console.log(round(2.15, 1));
console.log(round(21.5, -1));
console.log(round(626.3, -3));
console.log(round(-50.55, -2));20Explain
Common mistakes
Clicking "decrease decimal" and calling the number rounded.
That is number formatting. The cell looks rounded, but formulas still use every digit. Only ROUND changes the stored value.
Rounding only the grand total.
Each line still holds unrounded amounts, so the visible lines don't add up to the visible total. Round each amount where it is calculated.
Writing =ROUND(A2) in Excel.
Excel requires num_digits. Sheets accepts the formula and rounds to a whole number, so a sheet that works in Sheets can stop at this formula in Excel.
Expecting -1.475 to round to -1.47.
Halfway rounds away from zero by size, so the result is −1.48.
21
Summary
- Number formatting changes what you see, not what is stored.
- ROUND(number, digits): halfway rounds away from zero; negative digits round left of the point.
- Excel requires the digits argument; Google Sheets defaults it to 0.
- Round money where it is calculated so visible numbers add up.