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

Unit math with certain compounds #9

Closed
Vindaar opened this issue Jul 3, 2021 · 1 comment
Closed

Unit math with certain compounds #9

Vindaar opened this issue Jul 3, 2021 · 1 comment

Comments

@Vindaar
Copy link
Member

Vindaar commented Jul 3, 2021

A note on certain compounds like Liter, Acre (the only two compounds that have no UnitKind that is its base type).

Currently our implementation is confused by compound units that are not defined as their own actual unit. So Meter³, which is the base of Liter is not actually considered for auto conversion (only for type checking).

That means math like the following has a weird quirk:

block:
  let x = 1.Liter
  let y = 1.m³
  doAssert type(x + y) is Liter
  doAssert type(y + x) is Meter³

It wouldn't be too bad. The problem is the scale conversions are applied in both cases. So in the first case the actual number does just become 1.001. But it thinks it's liters!

@Vindaar
Copy link
Member Author

Vindaar commented Jul 27, 2022

This was fixed as part of the declarative unit / quantity rewrite in PR #24.

@Vindaar Vindaar closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant