Method Deck / units

Energy conversion

Converts an energy quantity between J, kJ, kWh, cal, kcal, BTU, and Wh using exact NIST SP 811 joule-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 joule-equivalent of from_unit and of to_unit.
  2. Convert the input to joules: joules = value * j_per(from_unit).
  3. Convert joules to the target unit: result = joules / j_per(to_unit).
  4. Round result to 6 significant figures.

Constants

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"value":1,"from_unit":"kWh","to_unit":"kJ"}3,600.00 kJ
test vector: kilocalories to joules{"value":1,"from_unit":"kcal","to_unit":"J"}4,184.00 J
test vector: BTU to joules{"value":1,"from_unit":"BTU","to_unit":"J"}1,055.06 J

Published card