+, -, %, the comparisons, min, max and sort need both sides in the same unit: adding
metres to seconds is a bug. * and / combine units instead (m / s is m/s). A plain number
has no unit, so it can scale a value (2.0 * d) but not be added to one; a literal 0 or 0.0
fits any unit.
Wrong#
fn total(d: float<m>, t: float<s>): float<m> = d + tFixed#
fn total(d: float<m>, t: float<s>, v: float<m/s>): float<m> = d + v * tCommon causes#
- Adding values in different units (
mandkm): convert with a factor,x * 1000.0<m/km>. - Adding a plain number to a unit value: write the unit on the literal,
d + 1.0<m>. - Units that differ only by an exponent (
mvsm^2): an area was used as a length.