Rounding calculator

Round a number to decimal places and see why the answer is what it is — including the value binary is really holding, which is where 2.675 goes wrong everywhere else. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.

Why two calculators give you different answers

Ask the internet to round 2.675 to two decimal places and you will be told 2.68, and told 2.67, and never told why. Both answers are being produced honestly. The disagreement is not about rounding at all.

The number you typed is not the number in the machine

Computers hold decimals in binary, and binary cannot represent 2.675 any more than decimal can represent a third. What is actually stored is the nearest value binary can reach:

2.67499999999999982236431605997495353221893310546875

That is below the halfway point, so it rounds down. 2.67 is arithmetically correct for the number that is really there, and no tie rule was involved, because there was no tie.

Where 2.68 comes from

Almost every rounding tool uses the same shortcut: multiply by a hundred, round to a whole number, divide by a hundred. And 2.675 × 100 is exactly 267.5 — the multiplication lands on a value binary can hold, which happens to be the halfway point. So the shortcut manufactures a tie that was not there, throws away the very digits that decided the answer, and then rounds the tie upward.

This page does not multiply. It works on the exact decimal above, digit by digit, and it tells you what the shortcut would have said so you can see when the two part company.

Halfway is a choice, not a fact

When a value really is exactly halfway — 2.5 to a whole number, 0.125 to two places — there is no arithmetically correct answer. There is only a convention, and there are two:

Half up2.5 → 3, 3.5 → 4, −2.5 → −3. What school teaches. Biased: over many values every half goes the same way, so totals creep upward.
Half to even2.5 → 2, 3.5 → 4. Halves go to whichever neighbour is even, so the ups and downs cancel. Called banker's rounding, specified by IEEE 754, and what Python's round() does. This is what money uses.

Note that JavaScript's own Math.round is neither of these at the edges: it rounds halves towards positive infinity, so Math.round(-2.5) is −2, not −3.

Round once, at the end

Rounding 2.446 to two places gives 2.45, and rounding that to one gives 2.5. Rounding 2.446 straight to one place gives 2.4. Each rounding throws away the evidence the next one needed. Carry the full value through a calculation and round the answer, not the steps.

What it will not do

Where to go next