convert
Converts a number from one unit to another, such as feet to centimetres or Fahrenheit to Celsius.
Details #
convert(value, from, to) takes three arguments and returns a number: the value measured in the to unit.
Units are named in full or abbreviated, in any case: ft, feet, cm, kg, lb, L, gal, F, °C, mph, km/h, GB, GiB, min, h, deg, kWh, psi. The families are length, mass, volume, temperature, speed, area, data size, duration, angle, energy, power and pressure. Both units must be in the same family.
The same conversions work in the palette: type 3 ft in cm after ⌥Space.
Parameters #
Takes 3 arguments.
{{ convert(text, b, c) }}
Examples #
convert(3, "ft", "cm")91.44round(convert(72, "F", "C"), 1)22.2convert(1, "GiB", "MB")1073.74Gotchas #
An unknown unit is an error:
convert() doesn't know the unit 'furlongs'.Units from different families are an error:
convert() can't turn kg into cm.The result is floating point; wrap it in round for a tidy number.