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

Arithmetic with affine units results in rational when integer would suffice #757

Open
sostock opened this issue Jan 3, 2025 · 0 comments
Labels
affine affine quantities like °C, °F, …

Comments

@sostock
Copy link
Collaborator

sostock commented Jan 3, 2025

When adding a temperature difference in K to a temperature in °C, one often wants to have the result in °C as well. ContextUnits can be used to achieve this.

julia> x = 5 * ContextUnits(°C, °C)
5 °C

julia> x + 3K
8//1 °C

However, the result has numerical type Rational{Int} even though Int would be just fine. The reason for this is that the + method in this case converts both quantities to K to add them before converting the result back to °C.

@sostock sostock added the affine affine quantities like °C, °F, … label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affine affine quantities like °C, °F, …
Projects
None yet
Development

No branches or pull requests

1 participant