We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9681358 + 2faec6a commit 09145e6Copy full SHA for 09145e6
src/int/sdiv.rs
@@ -33,9 +33,10 @@ macro_rules! mod_ {
33
#[cfg_attr(not(test), no_mangle)]
34
pub extern "C" fn $intrinsic(a: $ty, b: $ty) -> $tyret {
35
let s = b >> (<$ty>::bits() - 1);
36
- let b = (b ^ s) - s;
+ // NOTE(wrapping_sub) see comment in the `div` macro
37
+ let b = (b ^ s).wrapping_sub(s);
38
let s = a >> (<$ty>::bits() - 1);
- let a = (a ^ s) - s;
39
+ let a = (a ^ s).wrapping_sub(s);
40
41
let r = urem!(a as $uty, b as $uty);
42
($conv)((r as $ty ^ s) - s)
0 commit comments