# Changelog

## 0.7.0

The first release. UCUM, the Unified Code for Units of Measure, for Elixir: read, check,
convert and name unit codes as the standard defines them.

**Reads all of UCUM** (spec/01)

- Its whole grammar: products, quotients, a leading `/`, integer exponents and factors,
  terms in parentheses to any depth (`g/(m.s2)`), the atoms `10*` and `10^` (`10*3/uL`),
  and annotations (`{request}/s`), which have no unit meaning.
- Its essence table itself, version 2.2 (2024-06-17): `priv/ucum-essence.xml`,
  Regenstrief's file unmodified, from which the library is compiled. All 24 prefixes and
  312 units, with UCUM's print symbols; no definition is written by hand.
- The 41 arbitrary units (`[IU]`, `[arb'U]`), each a dimension of its own that converts
  only to itself.
- The case-insensitive codes, through `case_sensitive/1` (`MM[HG]` is `mm[Hg]`).
- A code's numbers have a bound, 2⁶⁵⁵³⁶, decided before anything is computed, so
  `km999999` is `{:too_large, code}` at once instead of exhausting the machine; what
  cancels between a code's components cancels first (`km999999/km999999` is `{1, 1}`).

**Answers** (spec/02)

- `parse/1`, `valid?/1`, `dimension/1` in UCUM's seven base dimensions, the exact
  `factor/1` (a rational, π kept as a power), `kind/1`, `symbol/2`, `name/1` (in the form
  of the UCUM functional tests: `km/h` is `(kilometer) / (hour)`) and `canonical/1`.
- `conversion/2`, the exact scale and offset between two codes, and `convert/3`, a value
  between them, through every special unit's function as well (`dB`, `Np`, `[pH]`,
  `dB[SPL]`, `[p'diop]`, the homeopathic potencies). `convert/2` applies a resolved
  conversion to a value without reading the codes again, for converting many values.
- `multiply/2` and `divide/2`: the product and quotient of two quantities, in base units.
- The table's own lookups: `atom/1`, `prefix/1`, `atoms/0`, `prefixes/0`.

**Exact, and never past a float's range** (spec/02 §9)

- A value is taken as the exact number it is, the scale and offset are exact, and the
  answer is rounded once: the nearest float. π is held to 576 bits, so a π scale rounds
  once too (`[pi]1000` in `10*497` is the nearest float).
- An answer past a float's range is `{:error, :out_of_range}` (with the value and codes
  from `convert/3`), not an `ArithmeticError`; one inside it is given whatever the size
  of its parts (the integer 10⁴⁰⁰ `m` is 10.0 `10*399.m`); integers of any size are
  values.

**Errors are values** (spec/00 §3, spec/03)

- Every function answers `{:ok, value}` or `{:error, reason}`, its `!` twin the value or
  `Ucum.Error`, and nothing else raises, for an argument of any shape. `format_error/1`
  writes any reason as a sentence, and a refusal costs no more to write than to answer:
  a caller's term is shown in at most 40 characters.

**Conformance** (spec/04)

- The UCUM functional tests (Ucum-java's `UcumFunctionalTests.xml`, 573 cases) run with
  the test suite: **572 of 573 pass**. The one that does not names the empty string,
  which the file and UCUM's grammar themselves call no code (spec/04 §3).

No runtime dependency, no process, no state, no file read. Elixir 1.18 or later.
