-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add Stable Div Rem #32
base: main
Are you sure you want to change the base?
Conversation
You may notice that I included a compiler hint for in some of the divide by zero checks. e.g.: Inequality operators (e.g. <=, >) are overloaded with the The In LLVM, the lexicographical comparison is translated to two However, the compiler seems to inconsistently elide redundant if a == 0 {
unsafe { unreachable_unchecked() }
}
if a == 0 {
panic!();
} compiles to a single if a > u128::MAX {
unsafe { unreachable_unchecked() }
}
if a == 0 {
unsafe { unreachable_unchecked() }
}
if a == 0 {
panic!();
}
_ = U256::new(3) / a; compiles to a 256-bit So, you may ask, why not use a custom implementation of |
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.
Wow! Thanks so much for this, just a small nit on the alignment.
… unrelated change.
Fixed the alignment. The other change I made was to the docs and doc tests of some methods. One could argue it was better before, but this way makes it more consistent with |
I found an error. In the std library, overflow is a guaranteed panic even without overflow checks. I made this depend on debug assertions. |
closes #11