Units
Convert values between units (length, mass, temperature, energy, pressure, data and more), compute expressions with units and change SI prefixes, with exact decimal results. Typical uses: engineering calculations, normalizing data from different sources.
unit convertunit calcunit calcunit listunit listunit prefix

unit convert <value> <from> <to>


Description

    Convert a value from a unit to another unit of the same quantity

Parameters

    value:   The value - Number - required
    from:   The unit of the value - String - required
    to:   The target unit - String - required
admin
unit convert 100 "km/h" "m/s"
mentdb
27.7777777777778
admin
unit convert 100 degC degF
mentdb
212
Temperature
admin
unit convert 37 "degC" "degF"
mentdb
98.6
Pressure
admin
unit convert 1 "atm" "Pa"
mentdb
101325
Energy
admin
unit convert 1 "kWh" "J"
mentdb
3600000
Data
admin
unit convert 1 "GiB" "MB"
mentdb
1073.741824
Length: miles to km
admin
unit convert 26.2 "mi" "km"
mentdb
42.1648128
Speed: knots to km/h
admin
unit convert 20 "kn" "km/h"
mentdb
37.04
Temperature: kelvin to degC
admin
unit convert 300 "K" "degC"
mentdb
26.85
Angle: degrees to radians
admin
unit convert 180 "deg" "rad"
mentdb
3.14159265358979
Energy: calories to joules
admin
unit convert 250 "kcal" "kJ"
mentdb
1046
Pressure: bar to psi
admin
unit convert 2.2 "bar" "psi"
mentdb
31.908302300646
Not the same quantity: error
admin
unit convert 1 "m" "kg"
mentdb
Sorry, an error appears (incompatible units: m (length) and kg (mass)).
Used in use cases (51 recipes)

    Physicist › Skydiver with quadratic drag: tanh and acosh
    Thermodynamics & heat transfer › Carnot limit of a heat pump
    Nuclear & radiation physicist › Activity of a check source today
    Atomic & quantum physicist › Atomic units: the constant family against const list
    Acoustics engineer › Doppler shift of a passing siren
    Metrologist › GUM uncertainty budget of a pendulum measurement of g
    and 45 more in the Use cases
Often used with

    math round_sig  ·  num solve  ·  math eval  ·  string regexp_extract  ·  const get  ·  unit calc  ·  json load select  ·  math rad_to_deg

unit calc <expression>


Description

    Compute an expression with units (the result in SI units: N, J, W, Pa, V, ohm... when they match; display format: session variable [_format], as math calc). The units follow the numbers (3 m, 9.81 m/s^2, 2 kohm); a number followed by its unit binds first: 3 m / 2 s = (3 m)/(2 s). Functions: sqrt, abs, sin, cos, tan (angle in rad or deg), exp, ln, log10... Constants: _c, _h, _k, _NA, _G, _e, _me, _R... with their unit (see 'const list'). Variables: [m] (number or quantity: -> "[v]" "3 m/s"). Adding m and s is an error. degC and degF (offset) can only be converted alone: use K in the computations

Parameters

    expression:   The expression with units (ex: "230 V * 10 A", "_h*_c/(500 nm)", "[m]*9.81 m/s^2") - String - required
admin
unit calc "3 m / 2 s"
mentdb
1.5 m/s
admin
unit calc "_NA*_k"
mentdb
8.31446261815324 J/(K*mol)
Power of a resistor P = U^2 / R
admin
unit calc "(12 V)^2 / (4 ohm)"
mentdb
36 W
Force of gravity on 75 kg
admin
unit calc "75 kg * _g0"
mentdb
735.49875 N
Kinetic energy
admin
unit calc "0.5 * 1200 kg * (100 km/h)^2"
mentdb
462962.962962963 J
Ideal gas: volume of 1 mol at 0 degC and 1 atm
admin
unit calc "1 mol * _R * 273.15 K / (1 atm)"
mentdb
0.0224139695450141 m^3
Energy of a battery of 2000 mAh at 3.7 V
admin
unit calc "2000 mAh * 3.7 V"
mentdb
26640 J
Density in kg/m3
admin
unit calc "2.5 kg / (1 L)"
mentdb
2500 kg/m^3
Speed of a wave: lambda f
admin
unit calc "0.5 m * 440 Hz"
mentdb
220 m/s
Ohm law U = R I
admin
unit calc "4.7 kohm * 2 mA"
mentdb
9.4 V
Pressure under 10 m of water
admin
unit calc "1000 kg/m^3 * _g0 * 10 m"
mentdb
98066.5 Pa
Inconsistent units: error
admin
unit calc "3 m + 2 s"
mentdb
Sorry, an error appears (cannot add m and s (position 10 in '3 m + 2 s')).

unit calc <expression> <unit>


Description

    Compute an expression with units and give the result as a number in the target unit (the dimensions must match)

Parameters

    expression:   The expression with units (ex: "5 V / 2 kohm", "25 degC") - String - required
    unit:   The target unit (ex: "mA", "km/h", "MeV", "degF") - String - required
admin
unit calc "_h*_c/(500 nm)" "eV"
mentdb
2.47968396866401
admin
unit calc "60 W * 2 h" "kWh"
mentdb
0.12
Volume of 1 mol of ideal gas in L
admin
unit calc "1 mol * _R * 273.15 K / (1 atm)" "L"
mentdb
22.4139695450141
Wavelength of a photon of 2 eV in nm
admin
unit calc "_h*_c/(2 eV)" "nm"
mentdb
619.920992166001
Consumption: 6 L/100 km in miles per gallon (inverse)
admin
unit calc "100 km / (6 L)" "mi/gal"
mentdb
39.2024305555556
Body temperature
admin
unit calc "98.6 degF" "degC"
mentdb
37
Speed in km/h
admin
unit calc "100 m / (9.58 s)" "km/h"
mentdb
37.5782881002088
Energy of a battery in kWh
admin
unit calc "75 Ah * 12 V" "kWh"
mentdb
0.9
Power of a car in hp
admin
unit calc "110 kW" "hp"
mentdb
147.512429855453
Wavelength of a radio at 100 MHz
admin
unit calc "_c / (100 MHz)" "m"
mentdb
2.99792458
Units not compatible: error
admin
unit calc "3 m" "kg"
mentdb
Sorry, an error appears (incompatible units: the result is in m, not in kg).
Worked example: Computing with units (unit calc checks the dimensions and gives the result in SI units, or in the unit asked.)
admin
#Worked example: Computing with units; #Kinetic energy of a car of 1.2 t at 90 km/h; unit calc "0.5 * 1.2 t * (90 km/h)^2" "kJ"; #Energy of a photon of 532 nm in eV; unit calc "_h*_c/(532 nm)" "eV"; #Current in a resistor of 2.2 kohm under 5 V; unit calc "5 V / 2.2 kohm" "mA"; #Pressure of 2 mol of gas in 10 L at 25 degC (ideal gas); unit calc "2 mol * _R * 298.15 K / (10 L)" "bar";
mentdb
4.95791405920478
Used in use cases (36 recipes)

    Physicist › Range of a baseball with air drag
    Optics & photonics › Step-index fiber: critical angle, NA and V number
    Thermodynamics & heat transfer › U-value and heat loss of an insulated wall
    Atomic & quantum physicist › Hydrogen: Balmer lines and ionization energy
    Chemist › Prepare a stock solution and dilute it
    Advanced physical chemist › Equilibrium yield from the Gibbs energy
    and 30 more in the Use cases
Often used with

    num solve  ·  unit convert  ·  math eval  ·  stat fit_model  ·  math round_uncertainty  ·  json load select  ·  num integrate  ·  num ode

unit list


Description

    List the quantities and their units (JSON object)

admin
unit list
mentdb
{ "length": ["m", "km", "cm", "mm", "um", "nm", "pm", "angstrom", "in", "ft", "yd", "mi", "nmi", "au", "ly", "pc"], ... }

unit list <quantity>


Description

    List the units of a quantity with their factor to the SI unit (and the offset for the temperatures)

Parameters

    quantity:   The quantity (length, mass, time, temperature, area, volume, speed, force, energy, power, pressure, angle, frequency, data) - String - required
admin
unit list "temperature"
mentdb
{"quantity": "temperature", "si": "K", "units": [ {"unit": "K", "name": "kelvin", "to_si": 1}, ... ]}
Units of pressure
admin
unit list "pressure"
mentdb
{"quantity": "pressure", "si": "Pa", "units": [ {"unit": "Pa", "name": "pascal", "to_si": 1}, {"unit": "hPa", "name": "hectopascal", "to_si": 100}, {"unit": "kPa", "name": "kilopascal", "to_si": 1000}, {"unit": "MPa", "name": "megapascal", "to_si": 1000000}, {"unit": "bar", "name": "bar", "to_si": 100000}, {"unit": "mbar", "name": "millibar", "to_si": 100}, {"unit": "atm", "name": "standard atmosphere", "to_si": 101325}, {"unit": "mmHg", "name": "millimetre of mercury", "to_si": 133.322387415}, {"unit": "torr", "name": "torr", "to_si": 133.322368421053}, {"unit": "psi", "name": "pound per square inch", "to_si": 6894.75729316836}, {"unit": "inHg", "name": "inch of mercury", "to_si": 3386.389} ]}
Units of energy
admin
unit list "energy"
mentdb
{"quantity": "energy", "si": "J", "units": [ {"unit": "J", "name": "joule", "to_si": 1}, {"unit": "mJ", "name": "millijoule", "to_si": 0.001}, {"unit": "kJ", "name": "kilojoule", "to_si": 1000}, {"unit": "MJ", "name": "megajoule", "to_si": 1000000}, {"unit": "eV", "name": "electronvolt", "to_si": 1.602176634E-19}, {"unit": "keV", "name": "kiloelectronvolt", "to_si": 1.602176634E-16}, {"unit": "MeV", "name": "megaelectronvolt", "to_si": 1.602176634E-13}, {"unit": "GeV", "name": "gigaelectronvolt", "to_si": 1.602176634E-10}, {"unit": "cal", "name": "calorie (thermochemical)", "to_si": 4.184}, {"unit": "kcal", "name": "kilocalorie (thermochemical)", "to_si": 4184}, {"unit": "Wh", "name": "watt-hour", "to_si": 3600}, {"unit": "kWh", "name": "kilowatt-hour", "to_si": 3600000}, {"unit": "MWh", "name": "megawatt-hour", "to_si": 3600000000}, {"unit": "BTU", "name": "British thermal unit (IT)", "to_si": 1055.05585262}, {"unit": "erg", "name": "erg", "to_si": 0.0000001} ]}
Unknown quantity: error
admin
unit list "foo"
mentdb
Sorry, an error appears (unknown quantity 'foo' (length, mass, time, temperature, area, volume, speed, force, energy, power, pressure, angle, frequency, data)).
Used in use cases (2 recipes)

    Thermodynamics & heat transfer › Radiation and convection loss of a steam pipe
    Metrologist › Calibrating a psi gauge against a kPa reference
Often used with

    constant physics_stefan_boltzmann  ·  math power  ·  stat max  ·  stat min  ·  string regexp_extract  ·  unit convert  ·  vector scale  ·  vector sub

unit prefix <value> <from> <to>


Description

    Change the SI prefix of a value (exact): Q R Y Z E P T G M k h da none d c m u n p f a z y r q (case sensitive; the micro sign is also accepted for u)

Parameters

    value:   The value - Number - required
    from:   The prefix of the value - String - required
    to:   The target prefix - String - required
admin
unit prefix 1500 k M
mentdb
1.5
admin
unit prefix 2.5 G none
mentdb
2500000000
Nanometers to meters
admin
unit prefix 532 n none
mentdb
0.000000532
Kilo to milli
admin
unit prefix 2.5 k m
mentdb
2500000
Micro to nano
admin
unit prefix 0.47 u n
mentdb
470
Without prefix to mega
admin
unit prefix 2500000 none M
mentdb
2.5
Used in use cases (3 recipes)

    Metrologist › Gauge block calibration with exact decimals
    Medical physicist › I-131 therapy: decay correction and MIRD thyroid dose
    Telecom & radar engineer › Ku band satellite downlink budget
Often used with

    bigdec precision  ·  bigdec round  ·  json load select  ·  unit convert  ·  arith frac_mul  ·  atom get  ·  bigdec abs  ·  bigdec compare