curatedapi

Percentage calculator

Percent of a number, what percent one number is of another, percent change, percent difference, and increase or decrease by a percent.

Which percentage question to answer. Options: percent_of: a% of b; what_percent: a is what percent of b; change: percent change from a to b; difference: percent difference between a and b; increase: b increased by a%; decrease: b decreased by a%
First number (see operation for its meaning).
Second number (see operation for its meaning).
More options: rounding and decimals
Precision and rounding
Rounding mode applied once to each result. Default half_even.
Round results to this many digits after the decimal point.
Round results to this many significant digits.

Examples

Example: 15% of 80

Result
The answer (a percentage for what_percent, change and difference).
12 exact
Formula used
The formula applied.
a / 100 × b

Rounding: Half even, 15 significant digits. Calculator math/percentage@1.

How it is calculated

see formula_used

Six everyday percentage questions in one calculator, each with its formula returned so the meaning of a and b is never in doubt. All arithmetic is exact.

  • Percent change divides by |a|, so a change from -50 to -25 is +50% (an increase).
  • Percent difference compares two values symmetrically, using their average magnitude as the base.

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/percentageVersion 1
curl https://api.curatedapi.com/v1/calc/math/percentage \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "percent_of",
    "a": "15",
    "b": "80"
  }'
The same call in Python
import os

import requests

payload = {
    "operation": "percent_of",
    "a": "15",
    "b": "80",
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/math/percentage",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "operation": "percent_of",
    "a": "15",
    "b": "80",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/math/percentage", {
  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_percentage at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="math/percentage" 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.