Created
July 9, 2021 17:15
-
-
Save CodeDrome/b45ca9f443a60f3cc5bc127530fbbc02 to your computer and use it in GitHub Desktop.
mathjsunits08.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function power() | |
{ | |
// demonstrate creating custom units | |
// this is metric horsepower, most commonly denoted by PS | |
// for pferd starke, German for horsepower | |
math.createUnit('ps', '735.49875 watt'); | |
// The math.js hp is mechanical horsepower or approx 746 Watts | |
const power = math.unit(100, 'hp'); | |
output(`power: ${power}`); | |
output(`power.to('kilowatt'): ${power.to('kilowatt')}`); | |
output(`power.to('ps'): ${power.to('ps')}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment