A value's unit differs from the unit expected there: a function argument, a return value, a
let with a type, a field or an assignment. The types are otherwise the same (float<m> where
float<s> is expected). float(x) (or int(x)) is the explicit way to drop a unit.
Wrong#
fn speed(d: float<m>, t: float<s>): float<m/s> = d * tFixed#
fn speed(d: float<m>, t: float<s>): float<m/s> = d / tCommon causes#
- A formula that multiplies where it should divide (the unit shows the mistake).
- A plain number where a unit is expected: write the literal with a unit,
2.0<m>. - A unit value passed to a function taking a plain
float: strip it withfloat(x).