Converts a mass between metric and avoirdupois units using exact NIST SP 811 kilogram-equivalents.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
value (number, from_unit, required) : The mass to convert
from_unit (string, required) one of: mg, g, kg, t, oz, lb, st : Unit of the input value
to_unit (string, required) one of: mg, g, kg, t, oz, lb, st : Unit to convert into
Outputs
result (to_unit): The converted mass
Steps
Look up the exact kilogram-equivalent of from_unit and of to_unit from the NIST SP 811 table.
Convert the input to kilograms: kilograms = value * kg_per(from_unit).
Convert kilograms to the target unit: result = kilograms / kg_per(to_unit).
Round result to 6 significant figures.
Constants
mg = 0.000001 kg (source: Guide for the Use of the International System of Units (SI))
g = 0.001 kg (source: Guide for the Use of the International System of Units (SI))
kg = 1 kg (source: Guide for the Use of the International System of Units (SI))
t = 1000 kg (source: Guide for the Use of the International System of Units (SI))
oz = 0.028349523125 kg (source: Guide for the Use of the International System of Units (SI))
lb = 0.45359237 kg (source: Guide for the Use of the International System of Units (SI))
st = 6.35029318 kg (source: Guide for the Use of the International System of Units (SI))
Sources
Guide for the Use of the International System of Units (SI) (National Institute of Standards and Technology, 2026-09-30T19:29:48Z) - oz and lb are exact avoirdupois definitions; st (stone) = 14 lb exactly; t is the metric tonne (1000 kg exactly).