瀏覽代碼

fix abs_diff bug

Aaron Kutch 4 年之前
父節點
當前提交
a0d09b00f8
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/int/mod.rs

+ 5 - 1
src/int/mod.rs

@@ -250,7 +250,11 @@ macro_rules! int_impl {
             }
 
             fn abs_diff(self, other: Self) -> Self {
-                (self.wrapping_sub(other) as $ity).wrapping_abs() as $uty
+                if self < other {
+                    other.wrapping_sub(self)
+                } else {
+                    self.wrapping_sub(other)
+                }
             }
 
             int_impl_common!($uty);