Function: Value Converters

ACF includes a set of common value converters that perform inline calculations. These converters are used just like functions, allowing you to easily convert values between different units and scales. Here are some examples of how to use value converters:

Example

// Calculate the distance to the moon - assuming it's 30 light seconds away
function moon_distanceKm()
    return lighty2m(1 / (365 * 24 * 60 * 2)) / 1000;  // 30 seconds
end

// Show temperature in three different units
function displayTemp(float temp)
    return format("Temp Celcius: %.1f, Farenheit: %.1f, Kelvin: %.1f", temp, c2f(temp), c2k(temp));
end

Value Converters

Here is a list of commonly used value converters in the ACF language:

Distance

Function Name Type of Argument Type of Result Formula Description
in2cm numeric double arg*2.54 Inches to Centimeters
cm2in numeric double arg/2.54 Centimeter to Inches
chain2m numeric double arg*20.1168 Chain to Meters
fathom2m numeric double arg*1.8288 Fathom to Meters
furlong2m numeric double arg*201.168 Furlong to Meters
leage2m numeric double arg*4828.032 Leage to Meters
lighty2m numeric double arg*9460730472581000.0 Light year to Meters
m2chain numeric double arg/20.1168 Meters to Chain
m2fathom numeric double arg/1.8288 Meters to Fathom
m2furlong numeric double arg/201.168 Meters to Furlong
m2leage numeric double arg/4828.032 Meters to Leage
m2lighty numeric double arg/9460730472581000.0 Meters to Light year
angstrom2m numeric double arg*1.0E-10 Angstrom to Meters
m2angstrom numeric double arg/1.0E-10 Meters to Angstrom
au2m numeric double arg*149597870700.0 Astronomical unit to Meters
m2au numeric double arg/149597870700.0 Meters to Astronomical unit

Volume

Function Name Type of Argument Type of Result Formula Description
fldr2ml numeric double arg*3.696691195313 Fluid dram (fl dr) to milliliter (ml)
floz2l numeric double arg*0.0295735295625 Fluid ounce (fl oz) to liter (l)
UKfloz2l numeric double arg*0.0284130625 Fluid ounce (UK)(fl oz) to liter (l)
gal2l numeric double arg*3.785411784 Gallon (gal) to liter (l)
UKgal2l numeric double arg*4.54609 Gallon (UK)(gal) to liter (l)
gill2l numeric double arg*0.11829411825 Gill to liter (l)
USdryPk2l numeric double arg*8.80976754172 Peck (US dry) (pk) to liter (l)
pt2l numeric double arg*0.473176473 Pint (liquid) (pt) to liter (l)
UKpt2l numeric double arg*0.56826125 Pint (UK) (pt) to liter (l)
USdryPt2l numeric double arg*0.5506104713575 Pint (US dry) (pt) to liter (l)
qt2l numeric double arg*0.946352946 Quart (liquid) (qt) to liter (l)
UKqt2l numeric double arg*1.1365225 Quart (UK) (qt) to liter (l)
USdryQt2l numeric double arg*1.101220942715 Quart (US dry) (qt) to liter (l)
ml2fldr numeric double arg/3.696691195313 Milliliter (ml) to fluid dram (fl dr)
l2floz numeric double arg/0.0295735295625 Liter (l) to fluid ounce (fl oz)
l2UKfloz numeric double arg/0.0284130625 Liter (l) to fluid ounce (UK)(fl oz)
l2gal numeric double arg/3.785411784 Liter (l) to gallon (gal)
l2UKgal numeric double arg/4.54609 Liter (l) to gallon (UK)(gal)
l2gill numeric double arg/0.11829411825 Liter (l) to gill
l2USdryPk numeric double arg/8.80976754172 Liter (l) to peck (US dry) (pk)
l2pt numeric double arg/0.473176473 Liter (l) to pint (liquid) (pt)
l2UKpt numeric double arg/0.56826125 Liter (l) to pint (UK) (pt)
l2USdryPt numeric double arg/0.5506104713575 Liter (l) to pint (US dry) (pt)
l2qt numeric double arg/0.946352946 Liter (l) to quart (liquid) (qt)
l2UKqt numeric double arg/1.1365225 Liter (l) to quart (UK) (qt)
l2USdryQt numeric double arg/1.101220942715 Liter (l) to quart (US dry) (qt)

Temperature

Function Name Type of Argument Type of Result Formula Description
c2f numeric double arg*9/5+32 Celsius to Fahrenheit
f2c numeric double (arg-32)*5/9 Fahrenheit to Celsius
c2k numeric double arg+273.15 Celsius to Kelvin
f2k numeric double (arg+459.67)*5.0/9.0 Fahrenheit to Kelvin
k2c numeric double arg-273.15 Kelvin to Celsius
k2f numeric double arg*9.0/5.0-459.67 Kelvin to Fahrenheit

Weight

Function Name Type of Argument Type of Result Formula Description
amu2g numeric double arg*1.6605402E-24 Atomic mass unit (amu) to gram (g)
carat2g numeric double arg/5.0 Carat (metric) to gram (g)
cental2kg numeric double arg*45.359237 Cental to kilogram (kg)
dram2g numeric double arg*1.771845195312 Dram (dr) to gram (g)
grain2g numeric double arg*0.06479891 Grain (gr) to gram (g)
hundredwt2kg numeric double arg*50.80234544 Hundredweight (UK) to kilogram (kg)
N2kg numeric double arg*0.1019716212978 Newton (earth) to kilogram (kg)
oz2g numeric double arg*28.349523125 Ounce (oz) to gram (g)
dwt2g numeric double arg*1.55517384 Pennyweight (dwt) to gram (g)
lb2kg numeric double arg*0.45359237 Pound (lb) to kilogram (kg)
quarter2kg numeric double arg*12.70058636 Quarter to kilogram (kg)
stone2kg numeric double arg*6.35029318 Stone to kilogram (kg)
troyOz2g numeric double arg*31.1034768 Troy ounce to gram (g)
g2amu numeric double arg/1.6605402E-24 Gram (g) to atomic mass unit (amu)
g2carat numeric double arg*5.0 Gram (g) to carat (metric)
kg2cental numeric double arg/45.359237 Kilogram (kg) to cental
g2dram numeric double arg/1.771845195312 Gram (g) to dram (dr)
g2grain numeric double arg/0.06479891 Gram (g) to grain (gr)
kg2hundredwt numeric double arg/50.80234544 Kilogram (kg) to hundredweight (UK)
kg2N numeric double arg/0.1019716212978 Kilogram (kg) to newton (earth)
g2oz numeric double arg/28.349523125 Gram (g) to ounce (oz)
g2dwt numeric double arg/1.55517384 Gram (g) to pennyweight (dwt)
kg2lb numeric double arg/0.45359237 Kilogram (kg) to pound (lb)
kg2quarter numeric double arg/12.70058636 Kilogram (kg) to quarter
kg2stone numeric double arg/6.35029318 Kilogram (kg) to stone
g2troyoz numeric double arg/31.1034768 Gram (g) to troy ounce

These value converters allow you to easily perform unit conversions within your ACF scripts, making it convenient to work with different units and scales.