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

Integer::next_multiple_of unexpectedly fails on MIN and -1 #43

Closed
jhpratt opened this issue Sep 3, 2021 · 0 comments · Fixed by #45
Closed

Integer::next_multiple_of unexpectedly fails on MIN and -1 #43

jhpratt opened this issue Sep 3, 2021 · 0 comments · Fixed by #45

Comments

@jhpratt
Copy link

jhpratt commented Sep 3, 2021

i8::MIN.next_multiple_of(-1) should return -128 (i8::MIN), but instead panics. The fix for this is to add if self == -1 { return self; } at the top of the method.

I have not checked, but it is certainly worth checking whether a similar situation applies with prev_multiple_of.

This is the only issue with the current implementation of next_multiple_of. It otherwise works as expected.

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

Successfully merging a pull request may close this issue.

1 participant