Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefixes not supported for all units #201

Open
mgreminger opened this issue Aug 3, 2023 · 3 comments
Open

Prefixes not supported for all units #201

mgreminger opened this issue Aug 3, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mgreminger
Copy link
Owner

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].

@mgreminger mgreminger added the enhancement New feature or request label Aug 14, 2023
@dvd101x
Copy link

dvd101x commented Aug 22, 2023

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.

@mgreminger
Copy link
Owner Author

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.

@dvd101x
Copy link

dvd101x commented Aug 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants