Skip to the calculator
Rule Calculator

Rounding Calculator

With number 2.5, decimal places 0, rounding comes to 3.000000 — rounded. It is reached in 6 steps, the last of which is floor(2.5 + 0.5) / 1, and each one is printed on the page with its numbers filled in. The formula is the one published by IEEE 754, not an approximation fitted to it.

A number rounded every way there is — half up, half to even, down, up and truncated — with the ones that disagree shown together.

Formula and sources checked · How we check

Number 2.5

3.000000

Rounded for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.

It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.

Rounded
3.000000
Half up — 2.5 goes to 3
floor(2.5 + 0.5) / 13
Half to even — 2.5 goes to 2
(round(2.5 / 2) * 2) / 12
Down, toward minus infinity
floor(2.5) / 12
Up, toward plus infinity
ceil(2.5) / 13
Truncated, toward zero
fix(2.5) / 12
The methods disagree here
1

Ask about this in the chat

Worked example

2.5 rounds to 3 by the rule taught in school and to 2 by the rule your computer uses. Both are correct and they are different conventions: round-half-to-even exists because always rounding .5 upward biases a long column of figures upward with it.

How to work it out yourself

  1. 1.Enter the number and how many decimal places you want. Negative places round to tens, hundreds and thousands.
  2. 2.Read the two half rules together where they disagree. Which one applies is a matter of what the number is for, not of which is more accurate.
  3. 3.Truncation is not rounding: it drops what is past the cut whatever it is, so 7.99 becomes 7. It is what a computer does when it converts a decimal to a whole number without being asked to round.

Where the two half rules part company

Where the two half rules part company
NumberRoundedHalf to even — 2.5 goes to 2Truncated, toward zero
0.51.00000000
1.52.00000021
2.53.00000022
3.54.00000043
4.55.00000044
5.56.00000065
6.57.00000066
7.58.00000087
8.59.00000088
9.510.000000109

Rounded to whole numbers. Half up always goes away from zero; half to even alternates.

The formula

  1. Half up — 2.5 goes to 3floor(2.5 + 0.5) / 1
  2. Half to even — 2.5 goes to 2(round(2.5 / 2) * 2) / 1
  3. Down, toward minus infinityfloor(2.5) / 1
  4. Up, toward plus infinityceil(2.5) / 1
  5. Truncated, toward zerofix(2.5) / 1
  6. The methods disagree here

Source: IEEE 754 — Standard for Floating-Point Arithmetic (round-to-nearest-even is the default mode), NIST Special Publication 811 — Guide for the Use of the International System of Units

Questions people actually ask

What is bankers’ rounding?
Round half to even: when a value sits exactly on the halfway point, it goes to whichever neighbour is even. 2.5 becomes 2, 3.5 becomes 4. Over a long column it removes the upward bias that always-round-up introduces, which is why it is the IEEE 754 default and the behaviour of most financial and scientific software.
Why does my spreadsheet round differently from my code?
Because they use different rules. Excel’s ROUND function rounds half away from zero; Python’s built-in round and most C libraries round half to even; JavaScript’s Math.round rounds half toward positive infinity, so it turns −2.5 into −2 rather than −3. All three are defensible and none of them is a bug.
Does rounding twice give the same answer?
Not always, and the failure is worth knowing about. Round 8.44 to one decimal and you get 8.4; round that to a whole number and you get 8, which is what rounding 8.44 directly gives too. But 8.45 rounded twice climbs to 9 while rounding it once leaves 8. Round once, from the original figure.
How do I round to the nearest hundred?
Use −2 decimal places. The scale factor becomes 0.01, so 1,250 rounds to 1,300 under half up and 1,200 under half to even. Negative places are the same arithmetic running the other way, and they are how a rounding function handles orders of magnitude.

Related

Where this one stops

Put this calculator on your site

Free, no attribution required beyond the link.

<iframe src="https://rulecalculators.com/embed/rounding" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Rounding Calculator"></iframe>
Did this answer your question?