calculator.onl
Categories50

Decimal rounding rules

Compare four rounding rules for the same decimal value. See which result each rule chooses at a midpoint, with negative numbers and when rounding to tens or hundreds.

Interactive illustration

Compare 2.5 and 3.5. Ties-to-even chooses different sides of the midpoint.

232.5
Type an optional sign, one to fifteen integer digits and optionally one to fifteen fractional digits. Write 0.5 for a half and include the leading zero. Spaces inside the number, thousands separators and scientific notation are outside the accepted input format.

Enter a whole number from minus nine through twelve. Positive values keep digits after the decimal mark. A negative value moves the rounding position to the left of the decimal mark, so minus one produces multiples of ten.

Updates as you type

Use a dot or comma for decimals. No thousands separators.

YOUR RESULT

Nearest, ties away from zero

3

Calculated from your inputs

Nearest, ties to even2
Floor toward −∞2
Ceiling toward +∞3

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

A worksheet shows 1.005 rounded to hundredths in two different ways. Both 1.00 and 1.01 lie exactly 0.005 from the original decimal, so the result depends on the tie rule. Enter the original digits and compare the four answers side by side. The two nearest rules are useful when a procedure specifies how to resolve a midpoint. Floor and ceiling answer a different practical question, such as which whole-number bounds contain a measurement.

Rounding in stages can change a result. From the original 1.2451, ties to even at two places gives 1.25. Rounding first to three places gives 1.245. Rounding that intermediate value again to two places gives 1.24. If the task calls for a final two-place answer, carry the original digits through the comparison.

Trailing zeros make the requested precision visible. For 1.005 at two places the ties-to-even answer appears as 1.00. The same value shown at whole-unit precision is 1. Exact decimal input also makes a useful test case when checking software that first converts a decimal to a binary floating-point number.

For inputs that already land on the requested grid, the lower bound, upper bound and both nearest results coincide. Try 12.30 at one decimal place, then increase the precision to three places. The numerical value stays the same while the displayed number of fractional digits changes.

What to enter

InputWhat it meansExample value
Decimal valueType an optional sign, one to fifteen integer digits and optionally one to fifteen fractional digits. Write 0.5 for a half and include the leading zero. Spaces inside the number, thousands separators and scientific notation are outside the accepted input format.2.5
Decimal placesEnter a whole number from minus nine through twelve. Positive values keep digits after the decimal mark. A negative value moves the rounding position to the left of the decimal mark, so minus one produces multiples of ten.0

How the calculation works

  1. Enter the original decimal before rounding. Use a point or comma as the decimal mark. Keep all the digits supplied by your source, including digits beyond the first one you plan to discard.
  2. Choose the position of the final digit. Zero selects whole units, two selects hundredths and minus two selects hundreds. This establishes the spacing between adjacent possible results on the number line.
  3. Find the adjacent values, then compare their distances from the input. One nearest value wins when the distances differ. At equal distances the tie rule takes over. The floor is the lower bound and the ceiling is the upper bound.
The formulaΔ = 10⁻ᵖ, x/Δ = k + f

A worked example

Set the number to 2.5 and the precision to zero. The two neighbours are 2 and 3. Ties away from zero chooses 3. Ties to even chooses 2 because its final retained integer digit is even. Now enter 3.5. The neighbours move to 3 and 4, and both nearest rules choose 4. In the first picture the midpoint sends the two rules to different ends of the interval. In the second picture the two paths meet.

Example you can load

What to enter
Result for this example · Nearest, ties away from zero3

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

The decimal is read as a string of digits and compared using integer arithmetic. This preserves the value you enter, including a decimal tie. A value copied from a previously rounded display has already lost any hidden precision. For a report, payment or data exchange, use the rule and rounding stage specified by the applicable instructions.

Frequently asked questions

What do floor and ceiling do to a negative decimal?

For minus 2.5 at whole-unit precision, the lower bound is minus 3 and the upper bound is minus 2. Floor therefore returns minus 3 and ceiling returns minus 2. The two nearest rules choose minus 3 for ties away from zero and minus 2 for ties to even.

How does ties to even work when rounding to hundreds?

For 250 the adjacent hundreds are 200 and 300. Think of these as two hundreds and three hundreds. The even neighbour is two hundreds, so ties to even gives 200. Ties away from zero gives 300. Inspecting only the final printed zeros would conceal the digit that decides the tie.

Does a discarded digit of five always mean a tie?

The entire remainder must equal half the step. At two decimal places, 1.2450 is exactly halfway between 1.24 and 1.25. Adding one to the last digit to get 1.2451 puts the value closer to 1.25. Both nearest rules select 1.25 in that case.