# units/v1 — Data size and temperature conversion

Converts data-size and temperature values, using Go's standard library
`math/big` so results don't silently lose precision the way `float64`
arithmetic would. Values are decimal strings in both directions, not
numbers — this keeps large byte counts and exact fractional results
(e.g. `98.6°F` → `37°C`) from being rounded by JSON's number handling.

Scope is deliberately narrow: data size and temperature only. Length,
angle, time, and other unit families aren't covered — ask if you need one
added.

### `POST /v1/units/convert/datasize`

**Request**

```json
{ "value": "1048576", "from": "B", "to": "MiB" }
```

Units: `bit`, `Kbit`, `Mbit`, `Gbit`, `Tbit` (bits, SI); `B`, `KB`, `MB`,
`GB`, `TB`, `PB` (bytes, SI, powers of 1000); `KiB`, `MiB`, `GiB`, `TiB`,
`PiB` (bytes, IEC, powers of 1024). Bit units spell out `bit` rather than
using a bare `b`/`B` case distinction, which is a well-known source of
100x errors.

**Response**

```json
{ "value": "1" }
```

Every data-size conversion is exact — the unit ratios only ever have 2 and
5 as prime factors, which always terminates in decimal.

### `POST /v1/units/convert/temperature`

**Request**

```json
{ "value": "100", "from": "C", "to": "F" }
```

Units: `C`, `F`, `K`. Conversion is offset-aware (not a bare multiplier) —
`0°C` is `273.15 K`, not `0 K`.

**Response**

```json
{ "value": "212" }
```

Celsius/Kelvin conversions are always exact; Fahrenheit conversions
involve a `/9` factor that doesn't terminate in decimal (e.g. `1°F`
intervals), so results are rounded to 10 decimal places, then trailing
zeros trimmed.

**Error response**

```json
{ "error": "unsupported unit \"furlong\": expected one of bit, Kbit, Mbit, Gbit, Tbit, B, KB, MB, GB, TB, PB, KiB, MiB, GiB, TiB, PiB" }
```

## Out of scope

Length, angle, time, mass, and other unit families; a `scale`/rounding-mode
parameter for temperature beyond the fixed 10-decimal-place default — ask
if you need one added.

## Files

- `units.go` — module wiring (routes, HTTP handlers)
- `convert.go` — pure conversion logic
- `convert_test.go` — known-vector and error tests
