Method Deck / units

Pressure conversion

Converts a pressure between Pa, kPa, bar, atm, psi, mmHg, and inHg using exact NIST SP 811 pascal-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 pascal-equivalent of from_unit and of to_unit.
  2. Convert the input to pascals: pa = value * pa_per(from_unit).
  3. Convert pascals to the target unit: result = pa / pa_per(to_unit).
  4. Round result to 6 significant figures.

Constants

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"value":1,"from_unit":"atm","to_unit":"psi"}14.6959 psi
test vector: bar to kPa{"value":1,"from_unit":"bar","to_unit":"kPa"}100.000 kPa
test vector: inHg to mmHg{"value":1,"from_unit":"inHg","to_unit":"mmHg"}25.4000 mmHg

Published card