HomeMath › Rounding Calculator

Rounding Calculator

Rounds a number to a given number of decimal places (negative for tens, hundreds, …) or significant figures using round-half-away-from-zero, and also reports the ceiling, floor and truncated values at the same precision.

When to use

You need a number rounded to a fixed number of decimals or significant figures, or its ceiling/floor at that precision, with the exact decimal behaviour (2.675 → 2.68).

Do not use when: You want a number written in scientific or engineering notation (use scientific-notation).

Formula

rounded = round_half_away(value × 10^p) / 10^p, where p = precision (decimals) or p = precision − 1 − ⌊log10|value|⌋ (significant figures); ceiling, floor and truncated use ⌈·⌉, ⌊·⌋ and trunc(·) instead

The decimal shift uses the exact decimal digits of the input, so ties such as 2.675 are recognised as ties and rounded away from zero (2.68) instead of following binary floating-point noise (2.67).

Inputs

ParameterTypeUnitRequiredDescription
valuenumberyesThe number to round. Range: ≥ -1000000000000, ≤ 1000000000000
precisionintegerdefault 2Decimal places when mode is decimals (negative rounds to tens, hundreds, …), or the number of significant figures (1–12) when mode is significant_figures. Range: ≥ -9, ≤ 12
modeenum: decimals | significant_figuresdefault decimalsWhether precision counts decimal places or significant figures.

Outputs

OutputTypeUnitDescription
roundednumberValue rounded half away from zero at the requested precision.
rounded_textstringThe rounded value written with the requested number of decimals, e.g. '2.68' or '12300'.
ceilingnumberSmallest value at that precision that is ≥ value.
floornumberLargest value at that precision that is ≤ value.
truncatednumberValue with the extra digits dropped (rounded toward zero).
decimal_places_usedintegerThe decimal-place count actually used (derived from the magnitude in significant-figure mode).

Example

2.675 to 2 decimals: {"value":2.675,"precision":2,"mode":"decimals"}{"rounded":2.68,"rounded_text":"2.68","ceiling":2.68,"floor":2.67,"truncated":2.67,"decimal_places_used":2}

12345.678 to 3 significant figures: {"value":12345.678,"precision":3,"mode":"significant_figures"}{"rounded":12300,"rounded_text":"12300","ceiling":12400,"floor":12300,"truncated":12300,"decimal_places_used":-2}

GET https://tttkmbb.com/api/v1/calculate/rounding?value=2.675&precision=2&mode=decimals

Machine access

Sources

FAQ

Which tie-breaking rule is used?

Round half away from zero: 2.5 → 3, −2.5 → −3, 2.675 → 2.68. Spreadsheets use the same rule; Python's round() and IEEE 754 default to round-half-to-even, which gives 2 for 2.5.

How do I round to the nearest hundred?

Use mode decimals with precision −2: 12345.678 → 12300.

Related calculators