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

Division of (some?) units is broken #16

Closed
Vindaar opened this issue Aug 6, 2021 · 1 comment
Closed

Division of (some?) units is broken #16

Vindaar opened this issue Aug 6, 2021 · 1 comment

Comments

@Vindaar
Copy link
Member

Vindaar commented Aug 6, 2021

Take the following code:

proc xrayEnergyToFreq(E: keV): s⁻¹ =
  ## converts the input energy in keV to a correct frequency
  result = E.to(Joule) / hp
echo 1.keV.xrayEnergyToFreq

it gives a CT error, because the resulting unit it computes is KiloGram²•Meter⁴•Second⁻³ instead of Second⁻¹.

The issue is that we are inverting both the power of the units as well as its base units for compounds. But the base units can never be inverted! That implies that the meaning of the compound unit was just changed.

The fix is easy. Just remove the inversion of the base powers in invert.

@Vindaar
Copy link
Member Author

Vindaar commented Oct 12, 2021

Closed in #17.

@Vindaar Vindaar closed this as completed Oct 12, 2021
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