Open mgreminger opened 1 year ago
mathjs allows for definitions of units that includes prefixes as needed. For units like BTU that already exists, you need to override the unit with a definition from another unit (as the override removes the unit as a first step).
math.createUnit(
'BTU',
{definition: '1055.05585262 J', prefixes: 'short'},
{override: true}
)
Maybe this method could aid to tweak units as needed.
Thanks for the suggestion. Yes, your suggestion would work, though I'm hesitant to pull the maintenance of the unit conversion factors into this project since it's not just BTU that's impacted. Most units in mathjs don't support prefixes so that would require overriding quite a few units.
Thanks for the consideration.
Another possibility that also works is to include variables in the mathjs
parser like stating that kBTU = 1000 BTU
then when you evaluate 10 kBTU
implicit multiplication would make the correct unit in BTU and you would make a division to convert back to the unit you need.
Nonetheless, I think it would be lees work with createUnit
but certainly more risk.
Math.js doesn't support prefixes for all unit types. Therefore, units like [kBTU/hour] cannot be used. Seems like Math.js only supports prefixes for SI units. Another solution would be to support multiplication factors in unit definitions such as [1000*BTU/hour].