> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Units and conversion

> Represent measurable quantities and convert compatible base, derived, and compound units

The unit model makes sensor values readable by people and convertible by software, including linear, non-linear, derived, and compound units.

| Item             | Value                                                                 |
| ---------------- | --------------------------------------------------------------------- |
| Namespace        | `urn:nfi:iot:u:1.0`                                                   |
| Definition model | Unit categories with one reference unit and zero or more alternatives |

## Model

A **unit category** groups compatible units representing the same measurable quantity. It has exactly one reference unit—normally an SI unit or a unit with a derivation to SI.

A regular **unit** defines reversible Reverse Polish Notation (RPN) operations that map its value to the category reference unit. A **compound unit** is a numeric factor multiplied by unit factors raised to integer exponents. Units without conversion operations are equivalent to their category reference unit.

```mermaid theme={null}
flowchart LR
  V[Input value + unit] --> P[Apply input prefix]
  P --> R[Convert to category reference]
  R --> T[Convert reference to target]
  T --> O[Choose output prefix and precision]
```

## Conversion algorithm

1. Look up both units and verify that their reduced dimensions/categories are compatible.
2. Apply any source prefix before evaluating unit operations.
3. Push the source value on the stack and evaluate its RPN operations top-to-bottom to reach the reference unit.
4. Evaluate the target operations in reverse, using the inverse of each operation, to leave the reference unit.
5. Apply a suitable target prefix and rounding policy.

The operation set includes constants and reversible arithmetic such as number, π, add, subtract, multiply, divide, power, logarithm, and negation. An implementation must reject an invalid stack program, a non-invertible conversion, or incompatible dimensions.

## Compound units

Reduce each factor recursively into a numeric multiplier and base-unit exponent map. Compatible compound units have the same normalized exponent map.

```text theme={null}
N  = kg·m·s⁻²
Pa = N·m⁻² = kg·m⁻¹·s⁻²
```

Do not compare display strings to test compatibility. Normalize definitions and dimensions instead.

## Sensor implementation rules

* Send a stable unit symbol with every quantity field for which magnitude depends on a unit.
* Preserve significant digits and quality metadata during conversion.
* Keep raw readings when a converted value will be used for audit or billing.
* Accept an unknown unit as a value you can display or store, but do not invent a conversion.
* Reject incompatible control inputs before changing device state.
