Home › Math › Ratio Calculator
Ratio Calculator
Simplifies a ratio a:b to lowest terms (decimals are scaled to integers first), expresses it as a decimal, as n:1 and as percentage shares, and optionally scales it to a new value of a.
When to use
You need to reduce a ratio, compare two quantities, or find the matching second value when the first is scaled (e.g. mixing or recipe ratios).
Do not use when: You are solving a/b = c/x with three known values (use proportion) or reducing a fraction with sign handling (use fraction-simplifier).
Formula
simplified = (A / g):(B / g) with A, B = a, b scaled to integers and g = gcd(A, B); decimal = a / b; new_b = new_a × b / a
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
a | number | yes | First term of the ratio a:b. Decimals are allowed (rounded to 6 decimal places before simplifying). Range: ≥ 0.000001, ≤ 1000000000 | |
b | number | yes | Second term of the ratio a:b. Range: ≥ 0.000001, ≤ 1000000000 | |
new_a | number | no | Optional new first quantity; returns the second quantity that keeps the same ratio. Range: > 0 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
simplified | string | a:b in lowest integer terms, e.g. '3:2'. | |
decimal | number | The ratio as a single number. | |
ratio_to_one | string | The ratio written as n:1. | |
one_to_ratio | string | The ratio written as 1:n. | |
share_a_percent | number | % | a / (a + b) × 100. |
share_b_percent | number | % | b / (a + b) × 100. |
new_b | number | new_a × b / a; only when new_a is given. |
Example
6:4, scale a to 9: {"a":6,"b":4,"new_a":9} → {"simplified":"3:2","decimal":1.5,"ratio_to_one":"1.5:1","one_to_ratio":"1:0.666667","share_a_percent":60,"share_b_percent":40,"new_b":6}
2.5:1.5: {"a":2.5,"b":1.5} → {"simplified":"5:3","decimal":1.6667,"share_a_percent":62.5}
GET https://tttkmbb.com/api/v1/calculate/ratio?a=6&b=4&new_a=9
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/ratio(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/ratio · Markdown: https://tttkmbb.com/math/ratio.md · JSON definition: https://tttkmbb.com/math/ratio.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="ratio" - OpenAPI operationId:
calculate_ratio - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Ratio (reference)
- Wolfram MathWorld – Ratio (reference)
FAQ
How are decimal ratios simplified?
Both terms are multiplied by the same power of 10 until they are integers (2.5:1.5 → 25:15) and then divided by their GCD (5:3).
What does 'share' mean?
The fraction of the total each term represents: in 3:2 the first part is 3 of 5, i.e. 60%.
Related calculators
- Proportion Calculator — Solve a/b = c/x for the missing value.
- Fraction Simplifier — The same reduction as a fraction.
- Aspect Ratio Calculator — Ratios of image and screen dimensions.