Casting/Conversions
Unit conversions for a number take place when that number is cast to another unit. This is because units are types in Stof, just like an "int" or a "float".
Casting With 'as' Keyword
Function Signature Casting
Incompatible Units
Compatible units are units in the same category. For example, any length unit can be cast to any other length unit, but cannot be cast to a temperature.
If operating with or casting to units of an incompatible type, the units become "undefined" and the value is treated as unitless.
Common Base Unit
When units are used in operations with compatible, but different units, Stof will pick a common base unit to present the returned value as. In a lot of cases, this is just the larger of the two units, which feels the most intuitive in practice.
Last updated