# Percentage calculator

Work out percentages: X% of Y, what percent X is of Y, percent change, and increase or decrease by X%.

- Endpoint: `POST https://setget.net/v1/tools/percent` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `percent`
- Page: https://setget.net/tools/percent

## Inputs

- `mode` (required, string, one of `percent_of`, `what_percent`, `change`, `increase`, `decrease`): What to work out: percent_of (X% of Y), what_percent (X is what % of Y), change (from X to Y), increase (Y plus X%) or decrease (Y minus X%).
- `x` (required, number, range -1000000000000000.0..1000000000000000.0): X: the percentage, or the first value, depending on the mode.
- `y` (required, number, range -1000000000000000.0..1000000000000000.0): Y: the amount the percentage applies to, or the second value.

## Example 1

```json
{"input":{"mode":"percent_of","x":15,"y":80}}
```

Result:

```json
{"result":12,"formula":"80 * 15 / 100 = 12","text":"15% of 80 is 12"}
```

## Example 2: Percent change

```json
{"input":{"mode":"change","x":80,"y":100}}
```

Result:

```json
{"result":25,"formula":"(100 - 80) / 80 * 100 = 25","text":"From 80 to 100 is an increase of 25%"}
```

## Example 3: What percent

```json
{"input":{"mode":"what_percent","x":30,"y":120}}
```

Result:

```json
{"result":25,"formula":"30 / 120 * 100 = 25","text":"30 is 25% of 120"}
```

**Why is a rise from 80 to 100 25%, but a fall from 100 to 80 only 20%?** Percent change is measured against the starting value. 20 is a quarter of 80 but only a fifth of 100.

**How do I take 20% off a price?** Use mode "decrease" with x = 20 and y = the price.
