Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 9, 2021 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeDrome/e7da24f1aa1923c0bd376510d246dbc5 to your computer and use it in GitHub Desktop.
Save CodeDrome/e7da24f1aa1923c0bd376510d246dbc5 to your computer and use it in GitHub Desktop.
mathjsunits09.js
function gallons()
{
// create imperial gallon unit
math.createUnit('impgal', '4.54609 liter');
// could do this, but probably not advisable!
// math.createUnit('gallon', '4.54609 liter', {override: true})
const usgallon = math.unit(1, 'gallon');
output(`usgallon: ${usgallon}`);
output(`usgallon.to('liter'): ${usgallon.to('liter')}`);
output("<br>");
const impgallon = math.unit(1, 'impgal');
output(`impgallon: ${impgallon}`);
output(`impgallon.to('liter'): ${impgallon.to('liter')}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment