Add Stable Div Rem#32
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 |
nlordell
left a comment
There was a problem hiding this comment.
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