Method Deck / units

Mass conversion

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

Outputs

Steps

  1. Look up the exact kilogram-equivalent of from_unit and of to_unit from the NIST SP 811 table.
  2. Convert the input to kilograms: kilograms = value * kg_per(from_unit).
  3. Convert kilograms to the target unit: result = kilograms / kg_per(to_unit).
  4. Round result to 6 significant figures.

Constants

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"value":10,"from_unit":"lb","to_unit":"kg"}4.53592 kg
test vector: stone to pounds{"value":1,"from_unit":"st","to_unit":"lb"}14.0000 lb
test vector: kilograms to ounces{"value":5,"from_unit":"kg","to_unit":"oz"}176.370 oz

Published card