We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
(-1).modulo(-2)
According to the implementation of trait method modulo
modulo
let result = self % rhs.clone(); if result < Self::Output::default() { result + rhs }
The modulo result will be wrong if result and rhs both are negative numbers. (-1).modulo(-2) gives the wrong result -3, it should be 1 anyway.
result
rhs
-3
1
The fix may be result + | rhs |? Namely, result + rhs.abs()
result + | rhs |
result + rhs.abs()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
According to the implementation of trait method
modulo
The modulo result will be wrong if
result
andrhs
both are negative numbers.(-1).modulo(-2)
gives the wrong result-3
, it should be1
anyway.The fix may be
result + | rhs |
? Namely,result + rhs.abs()
The text was updated successfully, but these errors were encountered: