Units

Several built-in types in SMW support units. Some support conversions between different units, and you can define your own types with Custom units.

The rest of this page describes a more complete design for units support that is yet to be implemented.

Units are mostly a Datatype based on Numbers and an Identifier.

Example: length:="35 km"

Although this case looks very simple, actually it isn't so for implementation. This is because the Parser need to understand different kinds of:
 * Numbertypes
 * Integers
 * Floats (including positive and negative Infinity)
 * Vectors and Matrices
 * Complex Numbers
 * &hellip;


 * Prefixes
 * &hellip;
 * nano
 * micro
 * milli
 * kilo
 * mega
 * giga
 * &hellip;


 * Units
 * meter
 * inch
 * yard
 * second
 * volt
 * &hellip;

and even complex Units which are composed from other Units. acceleration:="9.81 m/(s^2)"

Even it must be possible to derive new units with Formulas:

Unit:dB(var:x) -> 20 * Math:log(var:x) Unit:°C(var:x) -> (var:x - 273.15) * Unit:K

The most complete implementation of such unit support is probably in the GNU units program, though it is not internationalized.

Fundamental SI Units
These are easily implemented in current SMW, though prefix handling has to be repeated in each.

Namespaces
An additional, but complex to use, Technique might be to separate differt units using Namespaces. This could look like: SI:m For the SI-Unit Meter and Prefix:m For the Prefix m meaning Milli. So Millimeter could get expressed as: Prefix:m SI:m