-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: LCM panicked due to overflow #11131
Conversation
@@ -493,41 +493,6 @@ select gcd(a, b), gcd(c, d), gcd(e, f) from signed_integers; | |||
2 1 1 | |||
NULL NULL NULL | |||
|
|||
## lcm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests for lcm existed in two slts and have now been moved to math.slt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jonahgao -- the code looks good to me as do the tests. Nice work
let a = x.unsigned_abs(); | ||
let b = y.unsigned_abs(); | ||
let gcd = unsigned_gcd(a, b); | ||
// gcd is not zero since both a and b are not zero, so the division is safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks @alamb for the review. Merged it since future PRs might conflict on math.slt. |
* fix: LCM panicked due to overflow * add test * fix comment
Which issue does this PR close?
Closes #11104.
Rationale for this change
checked_mul
to detect multiplication overflow.What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No