Skip to content

Commit 76e3126

Browse files
AaronKutchdmakarov
authored andcommitted
fix abs_diff bug
1 parent 413d51d commit 76e3126

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/int/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ macro_rules! int_impl {
250250
}
251251

252252
fn abs_diff(self, other: Self) -> Self {
253-
(self.wrapping_sub(other) as $ity).wrapping_abs() as $uty
253+
if self < other {
254+
other.wrapping_sub(self)
255+
} else {
256+
self.wrapping_sub(other)
257+
}
254258
}
255259

256260
int_impl_common!($uty);

0 commit comments

Comments
 (0)