3.5.11.5 Convert

Description

Convert a number from one measurement system to another.

Syntax

double convert(double d, string str1$, string str2$)

Parameters

d

The number to be converted from one measurement system to another.

str1$

The unit for the number in one measurement system.

str2$

The unit for the result in another measurement system.

Available measurement systems and units for this function are listed in the

following tables. Note that, all the units are case-sensitive.

  • Weight and Mass
Units Meaning
"g" Gram
"sg" Slug
"lbm" Pound Mass (Avoirdupois)
"u" U (Atomic Mass Unit)
"ozm" Ounce Mass (Avoirdupois)
"grain"

(2019 SR0)

Grain
"cwt" (or "shweight")

(2019 SR0)

U.S. (short) hundredweight
"uk_cwt" or "lcwt" ("hweight")

(2019 SR0)

Imperial hundredweight
"stone"

(2019 SR0)

Stone
"ton"

(2019 SR0)

Ton
"uk_ton" or "LTON" ("brton")

(2019 SR0)

Imperial ton
  • Distance
Units Meaning
"m" Meter
"mi" Statute Mile
"Nmi" Nautical Mile
"in" Inch
"ft" Foot
"yd" Yard
"ang" Angstrom
"pica" Pica (1/6 inch)
"Pica" Point (1/72 inch)
"ell"

(2019 SR0)

ELL
"ly"

(2019 SR0)

Light year
"parsec" or "pc"

(2019 SR0)

Parsec
"survey_mi"

(2019 SR0)

U.S survey mile (statute mile)
  • Time
Units Meaning
"yr" Year
"day" Day
"hr" Hour
"mn" Minute
"sec" Second
  • Pressure
Units Meaning
"Pa" (or "p") Pascal
"atm" (or "at") Atmosphere
"mmHg" mm of Mercury
"psi" PSI
"Torr" Torr
  • Force
Units Meaning
"N" Newton
"dyn" (or "dy") Dyne
"lbf" Pound Force
"pond"

(2019 SR0)

Pond
  • Energy
Units Meaning
"J" Joule
"e" Erg
"c" Thermodynamic Calorie (4.184 J)
"cal" IT Calorie (4.1868 J)
"eV" (or "ev") Electron Volt
"HPh" (or "hh") Horsepower-hour
"Wh" (or "wh") Watt-hour
"flb" Foot-pound
"BTU" (or "btu") BTU
  • Power
Units Meaning
"HP" (or "h") Horsepower
"W" (or "w") Watt
"PS"

(2019 SR0)

Pferdestarke
  • Magnetism
Units Meaning
"T" Tesla
"ga" Gauss
  • Temperature
Units Meaning
"C" (or "Cel") Degree Celsius
"F" (or "fah") Degree Fahrenheit
"K" (or "kel") Kelvin
"Rank"

(2019 SR0)

Degress Rankine
"Reau"

(2019 SR0)

Degrees Reaumer
  • Liquid Measure
Units Meaning
"tsp" Teaspoon
"tbs" Tablespoon
"oz" Fluid Ounce
"cup" Cup
"pt" (or "us_pt") U.S. Pint
"uk_pt" U.K. Pint
"qt" Quart
"gal" Gallon
"l" (or "lt") Liter
  • Area

Minimum Origin Version Required: 2019 SR0

Units Meaning
"uk_acre" International acre
"us_acre" U.S. survey/statute acre
"ang2" (or “ang^2") Square angstrom
"ar" Are
"ft2" (or "ft^2") Square feet
"ha" Hectare
"in2" (or "in^2") Square inches
"ly2" (or "ly^2") Square light-year
"m2" (or "m^2") Square meters
"Morgen" Morgen
"mi2" (or "mi^2") Square miles
"Nmi2" (or "Nmi^2") Square nautical miles
"Picapt2" ("Pica2", "Pica^2" or "Picapt^2") Square Pica
"yd2" (or "yd^2") Square yards
  • Information

Minimum Origin Version Required: 2019 SR0

Units Meaning
"bit" Bit
"byte" Byte
  • Speed

Minimum Origin Version Required: 2019 SR0

Units Meaning
"admkn" Admiralty knot
"kn" Knot
"m/h" (or "m/hr") Meters per hour
"m/s" (or "m/sec") Meters per second
"mph" Miles per hour
  • Abbreviated Unit Prefixes

The following abbreviated unit prefixes can be used for any metric unit.

Prefix Multiplier Abbreviation
exa 1e+18 "E"
peta 1e+15 "P"
tera 1e+12 "T"
giga 1e+9 "G"
mega 1e+6 "M"
kilo 1e+3 "k"
hecto 1e+2 "h"
dekao 1e+1 "e"
deci 1e-1 "d"
centi 1e-2 "c"
milli 1e-3 "m"
micro 1e-6 "u"
nano 1e-9 "n"
pico 1e-12 "p"
femto 1e-15 "f"
atto 1e-18 "a"
yotta

(2019 SR0)

1E+24 "Y"
zetta

(2019 SR0)

1E+21 "Z"
yocto

(2019 SR0)

1E-24 "y"
zepto

(2019 SR0)

1E-21 "z"
  • Binary Prefix

Minimum Origin Version Required: 2019 SR0

Prefix Value Abbreviation
yobi 2^80 = 1208925819614629174706176 "Yi"
zebi 2^70 = 1180591620717411303424 "Zi"
exbi 2^60 = 1152921504606846976 "Ei"
pebi 2^50 = 1125899906842624 "Pi"
tebi 2^40 = 1099511627776 "Ti"
gibi 2^30 = 1073741824 "Gi"
mebi 2^20 = 1048576 "Mi"
kibi 2^10 = 1024 "ki"

Return

Return the result number after units conversion, or -1 for error.

Example

convert(2011, "yr", "day") = ;  // 734517.75
convert(1, "W", "C") = ;  // -1, error
convert(10, "kJ", "EeV") = ;  // 62415.097523028

double nKTemp = 273.0;
string strK$ = K;
string strF$ = F;
double dFTemp = convert(nKTemp, strK$, strF$);
dFTemp = ;  // 31.73