# manufacturing.tolerance-check
Checks one measurement against a nominal size and its tolerance, the way a
go/no-go gauge or an inspection sheet does:
lowerLimit = nominal + lowerDeviation
upperLimit = nominal + upperDeviation
passed = lowerLimit <= measured <= upperLimit
**Deviations, not a ± number.** Tolerances are given as the upper and lower
deviation from nominal, as ISO 286 writes them (`es`/`ei` for shafts,
`ES`/`EI` for holes), so both kinds of limit are one call:
- symmetric, 25 mm ± 0.05: `checkTolerance(m, 25000, 50, -50)`
- asymmetric, a 25 mm H7 hole (+0.021 / 0): `checkTolerance(m, 25000, 21, 0)`
- one-sided, a 25 mm g6 shaft (-0.007 / -0.020): `checkTolerance(m, 25000, -7, -20)`
The last is the case a "within ±tolerance of nominal" check gets wrong: a g6
shaft measured at exactly 25.000 mm is **too big**, 7 µm above its upper limit,
because both limits sit below nominal.
**Whole micrometres.** Every size is an integer number of micrometres (µm), so
limits and deviations are exact and all three languages agree; a reading of
25.0125 mm is 25013 µm after the gauge's own rounding. Every value must lie
within ±10^12 µm (1,000 km), which keeps every sum exact.
**Limits are inclusive.** A part measured exactly on a limit passes. `outBy` is
how far past the broken limit a reject is (always positive for a reject, 0 for a
pass), and `status` says which side: `above`, `below` or `within`.
The lower deviation may not be greater than the upper one. Negative sizes are
allowed, for coordinates and offsets measured from a datum.
Source: ISO 286-1:2010, Geometrical product specifications (GPS) - ISO code
system for tolerances on linear sizes, clause 3 (deviations and limits). The
H7 and g6 values for 25 mm are from its tables (IT6 = 13 µm, IT7 = 21 µm,
fundamental deviation g = -7 µm for sizes over 18 up to 30 mm).