Units
Overview
All Number values can be annotated with an optional unit. The unit must be an identifier defined by the standard unit database, which is standardized by the Unit enum.
Database
The unit database is managed by the Fantom open source community as part of the sys::Unit API. This database was originally based on the oBIX specification, but has since been expanded to allow multiple aliases to be used for each unit.
Each unit of measurement has a full name and zero or more symbols that are used as aliases for that unit. For example "square_meter" is the full name and the symbol alias is "m²". Some units might have multiple symbols. For example, "hour" has the symbols "hr" and "h". Some units like "day" have no symbols.
All unit identifiers are limited to the following characters:
- any Unicode char over 128
- ASCII letters
a-zandA-Z - underbar
_ - division sign
/ - percent sign
% - dollar sign
$
By convention, the symbol is the preferred notation. If there are multiple symbols, then the last symbol defined by the database is the preferred one.
Unitless
The unitless unit marks a number which is intentionally dimensionless: a
count or ratio with no standard unit. Use it where a unit is required but none
applies, such as a number point for a vendor configuration code. It corresponds
to the BACnet "no-units" engineering unit and the QUDT unit:UNITLESS.
Formatted display omits it, so 3unitless shows as "3".
Common Units
Below are some commonly used units. The full unit database is defined by the Unit enum.
--- Misc ---
percent, %
--- Area ---
square_meter, m²
square_foot, ft²
-- Currency ---
australian_dollar, AUD
british_pound, GBP, £
canadian_dollar, CAD
chinese_yuan, CNY, 元
euro, EUR, €
us_dollar, USD, $
--- Energy ---
kilowatt_hour, kWh
--- Power ---
kilowatt, kW
--- Pressure ---
kilopascal, kPa
pounds_per_square_inch, psi
inches_of_water, inH₂O
inches_of_mercury, inHg
--- Temperature ---
fahrenheit, °F
celsius, °C
--- Temperature Differential ---
fahrenheit_degrees, Δ°F
celsius_degrees, Δ°C
--- Time ---
millisecond, ms
second, sec
minute, min
hour, hr, h
day
week, wk
julian_month, mo
year, yr
--- Volumetric Flow ---
liters_per_second, L/s
cubic_feet_per_minute, cfm