# 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.

- Calculator id: `ratio` · Category: Math (`math`) · Tool name: `calculate_ratio`
- Canonical page: https://tttkmbb.com/math/ratio · This document: https://tttkmbb.com/math/ratio.md · JSON definition: https://tttkmbb.com/math/ratio.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `a` | number |  | required | First term of the ratio a:b. Decimals are allowed (rounded to 6 decimal places before simplifying). (min 0.000001, max 1000000000) |
| `b` | number |  | required | Second term of the ratio a:b. (min 0.000001, max 1000000000) |
| `new_a` | number |  | optional | Optional new first quantity; returns the second quantity that keeps the same ratio. (> 0) |

## Output

| Field | 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. |

## 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`

## Data Sources

- Wikipedia – Ratio — https://en.wikipedia.org/wiki/Ratio (reference, retrieved 2026-09-23)
- Wolfram MathWorld – Ratio — https://mathworld.wolfram.com/Ratio.html (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/ratio?a=…&b=…`
- `POST https://tttkmbb.com/api/v1/calculate/ratio` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/ratio · OpenAPI operationId `calculate_ratio` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "ratio", "inputs": {…}}`

## Example

- 6:4, scale a to 9: inputs `{"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: inputs `{"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
```

## Limitations

You are solving a/b = c/x with three known values (use proportion) or reducing a fraction with sign handling (use fraction-simplifier). All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Proportion Calculator](https://tttkmbb.com/math/proportion.md) — Solve a/b = c/x for the missing value.
- [Fraction Simplifier](https://tttkmbb.com/math/fraction-simplifier.md) — The same reduction as a fraction.
- [Aspect Ratio Calculator](https://tttkmbb.com/everyday/aspect-ratio.md) — Ratios of image and screen dimensions.
