Rounding Calculator

Enter a number and choose how many decimal places you want. Compare results across five different rounding modes and see the number rounded to various significant figures.

Report a Bug

Rounding Rules Explained

Rounding is something we all do intuitively, but the formal rules matter more than most people realize. When someone says "round to two decimal places," the procedure seems obvious: look at the third decimal digit, and if it's 5 or above, round the second digit up; if it's below 5, leave it alone. That's standard rounding, also called "round half up," and it's what you learned in elementary school.

But here's where things get interesting. What happens when the digit is exactly 5? With 2.345 rounded to two decimal places, do you get 2.34 or 2.35? Standard rounding says 2.35 — fives always round up. This introduces a slight upward bias when you're rounding large datasets, because the 5 case always pushes in the same direction.

That bias matters in finance and statistics. If a bank rounds every half-cent transaction upward, the rounding errors accumulate in the bank's favor. Multiply that by millions of daily transactions and the numbers add up. That's why banker's rounding exists — it rounds 5s to the nearest even number instead. So 2.345 becomes 2.34 (since 4 is even), but 2.355 becomes 2.36 (since 6 is even). Over large datasets, the rounds-up and rounds-down even out statistically.

Ceiling and floor are simpler. Ceiling always rounds toward positive infinity: 2.1 becomes 3, and -2.9 becomes -2. Floor always rounds toward negative infinity: 2.9 becomes 2, and -2.1 becomes -3. These aren't really "rounding" in the traditional sense — they're truncation in a specific direction — but they're essential in programming for things like pagination, array indexing, and resource allocation.

Significant Figures

Significant figures (or sig figs) represent the meaningful digits in a number, reflecting the precision of a measurement. They're different from decimal places. The number 0.00450 has three significant figures (4, 5, and the trailing 0), but five decimal places. Meanwhile, 4500 has two significant figures if the trailing zeros are just placeholders, or four if they were actually measured.

The rules for counting sig figs aren't complicated, but they have a few quirks. All nonzero digits are significant. Zeros between nonzero digits are significant (like the 0 in 4.05). Leading zeros are never significant — they're just positioning the decimal point. Trailing zeros after a decimal point are significant because someone deliberately measured or recorded them. The tricky case is trailing zeros in whole numbers like 1200, where it's ambiguous whether the zeros are significant or not. Scientific notation clears this up: 1.2 × 10³ has two sig figs, while 1.200 × 10³ has four.

When doing calculations, the result should match the precision of your least precise input. If you multiply 4.56 (three sig figs) by 1.4 (two sig figs), the answer should have two significant figures: 6.384 rounds to 6.4. For addition and subtraction, match the fewest decimal places instead. These rules prevent you from implying more precision than your measurements actually provide.

Science classrooms spend a lot of time on sig figs because publishing a result as 9.81274 m/s² when your stopwatch only measures to the nearest tenth of a second is misleading. The extra digits are computational artifacts, not real measurements.

Banker's Rounding and Why It Exists

Banker's rounding, technically called "round half to even" or "convergent rounding," solves a specific statistical problem that standard rounding creates. It's not just a banking thing — IEEE 754, the standard that governs how computers handle floating-point numbers, uses it as the default rounding mode.

The problem with always rounding 5 upward is systematic bias. Consider rounding a large set of numbers to the nearest integer. The digits 1 through 9 each have roughly equal probability of appearing in the ones place. Digits 1-4 always round down, digits 6-9 always round up, and that balances out. But the digit 5 always rounds up under standard rules, introducing a net upward push. Over millions of calculations, this bias can shift totals and averages measurably.

Banker's rounding fixes this by making the 5 case go in different directions depending on context. If the digit before the 5 is even, round down (keep it). If odd, round up (make it even). So 2.5 rounds to 2, but 3.5 rounds to 4. Over many cases, about half the 5s round up and half round down, eliminating the systematic bias.

The name "banker's rounding" comes from its historical adoption by financial institutions, though the practice is far older than modern banking. In practice, many regulatory bodies now specify which rounding method must be used for tax calculations, interest computations, and financial reporting, so the choice isn't always up to the individual. The IRS, for instance, generally follows standard rounding for tax returns, but currency exchange regulations in some countries mandate banker's rounding.

Python's built-in round() function uses banker's rounding, which surprises many programmers who expect round(2.5) to give 3. It gives 2. JavaScript's Math.round() uses standard rounding, where 2.5 rounds to 3. This inconsistency between languages has caused its share of bugs.

Rounding Errors in Programming

If you've ever seen a shopping cart total of $19.989999999999998 instead of $19.99, you've witnessed a rounding error. These errors come from the fundamental way computers store numbers, and understanding them is essential for any programmer working with decimals.

Computers store numbers in binary (base 2), not decimal (base 10). Just as 1/3 can't be represented exactly in decimal (it's 0.333... forever), the fraction 1/10 can't be represented exactly in binary. It becomes 0.0001100110011... repeating infinitely. Since computers have finite memory, they truncate this infinite binary expansion, introducing a tiny error.

The classic demonstration: in JavaScript or Python, 0.1 + 0.2 doesn't equal 0.3. It equals 0.30000000000000004. The individual rounding errors from representing 0.1 and 0.2 in binary combine during addition to produce a visible artifact.

For most scientific calculations, these errors are negligible. But for financial applications, they're unacceptable. A bank can't tell customers their balance is $1000.0000000000001. The standard solution is to avoid floating-point arithmetic for money entirely. Instead, store amounts in cents (or the smallest currency unit) as integers. $19.99 becomes 1999 cents. Integer arithmetic doesn't have rounding errors.

Another approach is using decimal libraries that perform arithmetic in base 10. Python's decimal module, Java's BigDecimal class, and JavaScript libraries like decimal.js all provide exact decimal arithmetic at the cost of some performance. When precision matters more than speed, these tools are the right choice.

Even with these solutions, rounding at the display level still requires choosing a strategy. That's where this calculator comes in handy — it lets you see exactly how different rounding modes affect the same number, so you can make informed decisions about which mode fits your use case.

Rounding Rules

Round(x, n) = ⌊x × 10ⁿ + 0.5⌋ / 10ⁿ

Standard rounding (half up) works by multiplying the number by 10 raised to the number of decimal places, adding 0.5, taking the floor, and dividing back. When the digit after the rounding position is exactly 5, standard rounding rounds up. Banker's rounding (half even) instead rounds to the nearest even number in that case, which reduces bias over many calculations. Ceiling always rounds up toward positive infinity, while floor always rounds down toward negative infinity.

Where:

  • x = The number to round
  • n = The number of decimal places

Example Calculations

Rounding Pi

Rounding 3.14159 to 2 decimal places using standard rounding.

The third decimal digit is 1, which is less than 5, so the second decimal digit (4) stays unchanged. Result: 3.14. This is the most commonly used approximation of pi for everyday calculations.

Banker's Rounding at the Half

Rounding 2.345 to 2 decimal places using banker's rounding.

Under standard rounding, 2.345 would round to 2.35. But with banker's rounding, the deciding digit is exactly 5, so we round to make the preceding digit even. Since 4 is already even, we round down, giving 2.34. If the number were 2.355, it would round to 2.36 (making 5 become 6, the nearest even digit).

Frequently Asked Questions

Rounding adjusts a number to the nearest value at a given precision level, considering the digits being removed. Truncating simply chops off digits without any adjustment. For example, truncating 3.789 to two decimal places gives 3.78, while rounding gives 3.79. Truncation is equivalent to floor rounding for positive numbers, but they differ for negative numbers: truncating -3.789 gives -3.78, while floor gives -3.79.

Use banker's rounding when you're processing large datasets where systematic bias could affect totals or averages. Financial institutions, statistical analysis, and scientific data processing benefit most from it. For single calculations, everyday estimates, or when following specific regulations that prescribe standard rounding, the regular half-up method is fine. Python uses banker's rounding by default in its built-in round() function.

Significant figures indicate how precise a measurement is. When you measure a table as 1.52 meters using a ruler with millimeter markings, reporting it as 1.52000 would falsely imply sub-millimeter precision. The three significant figures in 1.52 honestly reflect your measurement capability. In calculations, keeping track of sig figs ensures your result doesn't claim more precision than your inputs can support.

Computers store numbers in binary, and just as 1/3 produces an infinite repeating decimal (0.333...), the fraction 1/10 produces an infinite repeating binary. Computers must truncate this infinite expansion to fit in memory, introducing a tiny error. When 0.1 and 0.2 are added, their individual errors combine to produce 0.30000000000000004 instead of exactly 0.3. This is a fundamental limitation of binary floating-point arithmetic, not a bug.

Ceiling always rounds toward positive infinity (up), regardless of the digit being removed. Floor always rounds toward negative infinity (down). Neither one considers whether the removed digit is above or below 5. Ceiling of 2.1 is 3; floor of 2.9 is 2. For negative numbers: ceiling of -2.9 is -2 (toward positive infinity); floor of -2.1 is -3 (toward negative infinity). These functions are widely used in programming for allocating resources, calculating pages, and array index math.

Related Calculators