Sumivo · Mathematics

Rounding Calculator

Compare six exact rounding rules. Use 0 (or integer) for whole numbers, 2 for hundredths, −1 for tens or −2 for hundreds. Half-up means ties away from zero: −2.5 becomes −3, not −2 as with ties toward +∞.

01 / inputs

value
n

02 / result

Half-up (ties away from zero)

3

Rounding unit
10^0
Exact midpoint?
Yes

Calculation trace

  1. 10^0
    Choose the rounding unit
  2. 2 retained units; discarded digits: 5
    Split the magnitude into retained units and a remainder
  3. 2.5 ≈ 3
    Apply half-up

Discarded digits: 5. The discarded magnitude is exactly half of one rounding unit. Half-up ties go away from zero; half-down ties go toward zero; half-even ties keep an even retained integer.

ModeResult
Half-up (ties away from zero)3
Half-down (ties toward zero)2
Half-even (bankers rounding)2
Floor (toward −∞)2
Ceiling (toward +∞)3
Truncate (toward zero)2

    Maintained by Jack Shi

    §

    How it works

    The selected decimal place defines a power-of-ten unit. Exact integer division separates retained units from the discarded digits, then compares the remainder with half a unit. All six modes use that same exact comparison. Half-up chooses the nearest value with ties away from zero; half-down chooses the nearest with ties toward zero; half-even chooses the nearest with an even retained integer at a tie. Floor moves toward negative infinity, ceiling toward positive infinity, and truncate toward zero.

    Assumptions & limits

    • Half-up here means the school rule on the magnitude: −2.5 becomes −3. It does not mean ties toward positive infinity, which would make −2.5 become −2. Half-down ties go toward zero, not toward negative infinity.
    • Enter decimal strings or e/E notation, with at most 4096 characters and 2000 coefficient digits. Input and normalized exponents must be between −1000 and 1000. Places must be an integer from −2000 to 2000; 0 or integer means the ones place, −1 tens and −2 hundreds. Invalid inputs are rejected, never clamped.
    • Positive places preserve that many fractional digits, even for zero. Negative zero is normalized. This tool rounds a value to a place; it does not infer measurement precision. Half-even is also called bankers rounding and uses the tie principle of the IEEE default nearest-even mode. This tool uses decimal arithmetic, not a binary IEEE format.

    Verified runs

    Synthetic examples executed at build revision be2e0e4 on . Cards round decimal results to 6 significant figures; matching uses full precision and the tolerance below. Matches cover the displayed fields, not every possible input or clinical or engineering validation.

    • Inputs: Value: 0.125 dimensionless exact decimal; Decimal places: 2 decimal places

      Result: Result: 0.13 rounded decimal (expected Result: 0.13 rounded decimal) ✓

    • Inputs: Value: -0.01 dimensionless exact decimal; Decimal places: 0 decimal places

      Result: Result: 0 rounded decimal (expected Result: 0 rounded decimal) ✓

    • Inputs: Value: -150 dimensionless exact decimal; Decimal places: -2 decimal places

      Result: Result: -200 rounded decimal (expected Result: -200 rounded decimal) ✓

    How these runs were checked

    Method: rounding@1.0.0. Expectations come from the listed test fixtures or hand arithmetic; they are not copied from these executions. Omitted optional inputs use the method defaults. Run dates record execution, not expert review or fresh measurements.

    Download all verified runs (JSON) — full inputs, returned values, expectations, timestamps and buildRevision.

    • normal: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Result: 0.13 rounded decimal. Expected: Result: 0.13 rounded decimal. Expectation: packages/calculator-core/tests/rounding.test.ts
    • boundary: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Result: 0 rounded decimal. Expected: Result: 0 rounded decimal. Expectation: packages/calculator-core/tests/rounding.test.ts
    • sensitivity: . Absolute tolerance: 1e-10. Text and booleans match exactly. Full-precision result: Result: -200 rounded decimal. Expected: Result: -200 rounded decimal. Expectation: packages/calculator-core/tests/rounding.test.ts

    Reproduce from the source checkout with pnpm --filter @sumivo/web gen:verified-runs. A rebuild changes execution times; the revision identifies its Git starting point, including any uncommitted changes made for that build.

    §

    FAQ

    How do I round a number to two decimal places?
    Enter 2 for decimal places. The tool compares the discarded magnitude with 0.005. With half-up, 0.125 becomes 0.13; half-even makes it 0.12 because the retained 2 is even.
    How do you round negative numbers?
    The direction depends on the rule. At the ones place, −2.5 becomes −3 with half-up and floor, but −2 with half-down, half-even, ceiling and truncate.
    What is bankers rounding?
    Half-even rounding selects the nearest value and breaks exact ties by keeping an even retained integer: 2.5 becomes 2 and 3.5 becomes 4 at the ones place. A value above the midpoint, such as 2.5001, still becomes 3.
    How do I round to the nearest ten or hundred?
    Use −1 decimal places for tens or −2 for hundreds. With half-up, 150 rounded to hundreds is 200. Enter 0 or integer to round to a whole number.
    What is the difference between rounding and truncation?
    Truncation discards the remainder toward zero: −2.9 becomes −2. Nearest rounding uses the remainder to choose a neighbor, so half-up makes −2.9 become −3. Floor always moves toward negative infinity.
    §

    Related calculators

    §

    SOURCES