# Number base converter

Convert numbers between any bases from 2 to 36, such as binary, octal, decimal and hexadecimal.

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

## Inputs

- `value` (required, string): The number to convert. A 0x, 0b or 0o prefix is understood.
- `to_base` (required, integer, range 2..36): Base to convert to.
- `from_base` (optional, integer, range 2..36): Base the number is written in. Taken from the prefix, or 10, when left empty.
- `prefix` (optional, boolean, default `false`): Add 0x, 0b or 0o to the result when the target base is 16, 2 or 8.
- `group` (optional, integer, default `0`, range 0..16): Put a space between every this many digits, counted from the right. 0 turns it off.
- `uppercase` (optional, boolean, default `false`): Write letter digits in capitals.
- `precision` (optional, integer, default `20`, range 0..100): Most digits to give after the point for fractions.

## Example 1

```json
{"input":{"value":"ff","from_base":16,"to_base":2,"group":4}}
```

Result:

```json
{"text":"1111 1111","from_base":16,"to_base":2,"decimal":"255","exact":true}
```

## Example 2: Decimal to hex

```json
{"input":{"value":"-255","to_base":16,"prefix":true}}
```

Result:

```json
{"text":"-0xff","from_base":10,"to_base":16,"decimal":"-255","exact":true}
```

## Example 3: A fraction that never ends in binary

```json
{"input":{"value":"0.1","to_base":2,"precision":8}}
```

Result:

```json
{"text":"0.00011001","from_base":10,"to_base":2,"decimal":"0.1","exact":false}
```

**Why is "exact" false for 0.1 in binary?** Like 1/3 in decimal, 0.1 has no finite form in base 2. The digits are cut off (not rounded) at "precision" places.

**How are negative numbers shown?** With a minus sign in front. Two's complement is not used.

**Which digits do bases above 10 use?** 0 to 9 and then a to z, so base 16 uses 0-9 and a-f, and base 36 uses 0-9 and a-z.
