UnitParser code >
Unit Conversions
Parsing means recognising and adapting raw inputs to the target format; consequently, a library only recognising the string "m/s" as a valid (velocity) unit might be rightfully called parser. On the other hand, virtually any piece of software dealing with units supports conversions. That's why the unit conversion functionalities can be considered part of the most essential features of UnitParser.

It has to be noted that the unit prefixes are treated like numeric values associated with the given unit. For example, the operation new UnitP("1 kg") + new UnitP("1 g") doesn't involve a unit conversion, but just an operation between different values. Same ideas apply to situations accounting for different types of prefixes (e.g., new UnitP("1 kbit") + new UnitP("1 Kibit")).

Performing auto-conversions is other distinctive feature of UnitParser; also another side-effect of its permissive input policy. A situation like new UnitP("kg*ft/s2") (i.e., a force where SI and imperial constituent parts are being mixed up) is wrong and that's why an automatic conversion has to be performed. These auto-conversions certainly represent an additional layer of complexity despite relying on the standard conversion algorithm described below.

All the unit conversions go through the following steps (code stored in Operations_Private_Conversions.cs):