The compiler computes units at compile time, so x ** n on a value with a unit needs n to be
an integer literal (d ** 2.0 is m^2), an exponent can't have a unit, and sqrt needs every
exponent to be even (sqrt of m^2 is m, of m it has no unit).
Wrong#
fn side(area: float<m>): float<m> = sqrt(area)Fixed#
fn side(area: float<m^2>): float<m> = sqrt(area)Common causes#
- A variable exponent: strip the unit first,
float(x) ** n. sqrtof a value whose unit has an odd exponent.