units

See http://tcllib.sourceforge.net/doc/units.html

This tcllib library provides a conversion facility from a variety of scientific and engineering shorthand notations into floating point numbers. This allows application developers to easily convert values with different units into uniformly scaled numbers.

The units conversion facility is also able to convert between compatible units. If, for example, a application is expecting a value in ohms (Resistance), and the user specifies units of milliwebers/femtocoulomb, the conversion routine will handle it appropriately. An error will be generated if an incorrect conversion is attempted.

Values are scaled from one set of units to another by dimensional analysis. Both the value units and the target units are reduced into primitive units and a scale factor. Units are checked for compatibility, and the scale factors are applied by multiplication and division. This technique is extremely flexible and quite robust.

New units and new unit abbreviations can be defined in terms of existing units and abbreviations. It is also possible to define a new primitive unit, although that will probably be unnecessary. New units will most commonly be defined to accommodate non-SI measurement systems, such as defining the unit inch as 2.54 cm.