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

Prevent integer division with raw numerics #142

Merged
merged 7 commits into from
Jun 27, 2023
Merged

Prevent integer division with raw numerics #142

merged 7 commits into from
Jun 27, 2023

Conversation

chiphogg
Copy link
Contributor

This closes a loophole and makes the library more consistent.

Fixes #39.

This closes a loophole and makes the library more consistent.
@chiphogg chiphogg added the release notes: 🐛 lib (bugfix) PR fixing a defect in the library code label Jun 23, 2023
chiphogg added 6 commits June 22, 2023 22:05
There are a _lot_ of instances of this in the AV repo, mostly in
embedded code.  As I worked through updating them, I realized that
replacing these instances with `integer_quotient()` was making the code
worse.  I think what we're really worried about here is mixing integer
division with unit conversions.  This overload is the only one that
doesn't change the units.

We'll still provide `integer_quotient()` for this case just for
completeness, though.
I was running the wrong test.
@chiphogg chiphogg marked this pull request as ready for review June 24, 2023 19:23
@chiphogg chiphogg requested a review from geoffviola June 24, 2023 19:23
Copy link
Contributor

@geoffviola geoffviola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I thought mixing quantities and raw values was a little weird. But we know they are int and they are being used as ratios. So it should be OK.

@chiphogg chiphogg merged commit efeb15f into main Jun 27, 2023
@chiphogg chiphogg deleted the int-div#39 branch July 24, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: 🐛 lib (bugfix) PR fixing a defect in the library code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tighten up integer division checks on Quantity
2 participants