curatedapi

Rounding calculator

Round a number to decimal places, significant digits or a multiple, with any of seven rounding rules.

The number to round.
What to round to. Options: decimals: to a number of decimal places (negative rounds to tens, hundreds, ...); significant: to a number of significant digits; multiple: to the nearest multiple of a step, e.g. 0.05 for cash rounding
Decimal places (method decimals) or significant digits (method significant).
Step to round to (method multiple), e.g. 0.05.
Rounding rule. Options: half_up: to nearest, ties away from zero (2.5 → 3, -2.5 → -3); half_even: to nearest, ties to even (2.5 → 2, 3.5 → 4): banker's rounding; half_down: to nearest, ties towards zero (2.5 → 2); up: away from zero (2.1 → 3, -2.1 → -3); down: towards zero, i.e. truncate (2.9 → 2); ceiling: towards +∞ (2.1 → 3, -2.1 → -2); floor: towards −∞ (2.9 → 2, -2.1 → -3)

Examples

Result: Banker's rounding

Result
The rounded number, with trailing zeros kept (2.10).
2
Changed
False when the value was already exact at this precision.
yes
Difference
result − value, exactly.
-0.5

Calculator math/rounding@1.

How it is calculated

decimals: round(x·10ⁿ)/10ⁿ; multiple: round(x/m)·m; ties per the chosen mode

Rounds exactly (no binary floating point), so 2.675 to two places with half-up gives 2.68, not the 2.67 many programs print. Choose the rule explicitly: half-up, banker's rounding (half-even), half-down, up, down (truncate), ceiling or floor.

  • The rounding rule is the mode input; this calculator takes no options object.

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Use it from your code

POST /v1/calc/math/roundingVersion 1
curl https://api.curatedapi.com/v1/calc/math/rounding \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "2.5",
    "places": 0,
    "mode": "half_even"
  }'
The same call in Python
import os

import requests

payload = {
    "value": "2.5",
    "places": 0,
    "mode": "half_even",
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/math/rounding",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "value": "2.5",
    "places": 0,
    "mode": "half_even",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/math/rounding", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log((await response.json()).result);

MCP tool calc_math_rounding at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="math/rounding" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>

Use a public key registered for your site. Calculations are billed like API calls. How widgets work.

Related calculators

Add this calculator to your website

Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.

Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.