HomeMath › 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

ParameterTypeUnitRequiredDescription
anumberyesFirst term of the ratio a:b. Decimals are allowed (rounded to 6 decimal places before simplifying). Range: ≥ 0.000001, ≤ 1000000000
bnumberyesSecond term of the ratio a:b. Range: ≥ 0.000001, ≤ 1000000000
new_anumbernoOptional new first quantity; returns the second quantity that keeps the same ratio. Range: > 0

Outputs

OutputTypeUnitDescription
simplifiedstringa:b in lowest integer terms, e.g. '3:2'.
decimalnumberThe ratio as a single number.
ratio_to_onestringThe ratio written as n:1.
one_to_ratiostringThe ratio written as 1:n.
share_a_percentnumber%a / (a + b) × 100.
share_b_percentnumber%b / (a + b) × 100.
new_bnumbernew_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

Sources

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