Skip to content

Commit

Permalink
Added unit for pressure, inch of mercury (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
munnik authored Mar 13, 2021
1 parent f78511d commit 19b60e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pressure.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
TechAtmosphere = Pascal * 9.80665 * 1e4
Torr = Pascal * 133.3224
PoundsPerSquareInch = Pascal * 6.8948 * 1e3
InchOfMercury = Pascal * 3386.389
)

// Yoctopascals returns the pressure in yPa
Expand Down Expand Up @@ -286,3 +287,8 @@ func (p Pressure) Torrs() float64 {
func (p Pressure) PoundsPerSquareInch() float64 {
return float64(p / PoundsPerSquareInch)
}

// InchOfMercury returns the pressure in inch of mercury
func (p Pressure) InchOfMercury() float64 {
return float64(p / InchOfMercury)
}
1 change: 1 addition & 0 deletions pressure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ func TestPressure(t *testing.T) {
assertFloatEqual(t, 0.10197162129779283, (10000 * Pascal).TechAtmospheres())
assertFloatEqual(t, 75.00615050434136, (10000 * Pascal).Torrs())
assertFloatEqual(t, 1.4503683935719673, (10000 * Pascal).PoundsPerSquareInch())
assertFloatEqual(t, 2.9529980164712323, (10000 * Pascal).InchOfMercury())
}

0 comments on commit 19b60e0

Please sign in to comment.