3 ms·
Canonicalization is tough, and requires you to define some common ordering on your units. Systems will use an array of unit powers, so that if the array were d
by dastbe 11y ago
Canonicalization is tough, and requires you to define some common ordering on your units.
Systems will use an array of unit powers, so that if the array were defined as <Joules, Seconds, Newtons, Meters>, then acceleration would be <0,-2,0,1> and watts would be <1,-1,0,0>. Addition and subtraction require that your arrays are equal, and multiplication and division are pairwise additive/subtractive.
- jarrettc 11y agoWill the Rust compiler ever understand numbers in types? I.e. will the numbers ever be more than just part of the string that is the type name? If not, then I don't know how possible powers will be. Maybe the solution would be to define some types for commonly-used powers, e.g. PowN4, PowN3, PowN2, PowN1, Pow2, Pow3, Pow4. Users who needed higher powers could define those types themselves, I guess.
- steveklabnik 11y agoWe do desire type-level integers, yes. There hasn't been an RFC yet, though.
- sigterm 11y agoIs it tough? There are only seven fundamental units. https://en.wikipedia.org/wiki/SI_base_unit https://en.wikipedia.org/wiki/SI_base_unit Just represent every unit in terms of them then it's good. One problem with the array you came up is that the units are not orthogonal, since Joules = Newtons * Meters.
- jcranmer 11y agoActually, there's more "kinds" of units: radians (versus degrees) and steradians come to mind.
- masklinn 11y agoThese are dimensionless derived units in SI equivalence (respectively m/m and m2/m2)
- dastbe 11y agoSorry! I never really spent much time in the physical sciences, so I didn't know that. You would obviously not want to pick Joules as a fundamental unit.