fix u32 conversion sign
authoralfadur
Thu, 04 Jul 2019 19:21:56 +0300
changeset 15217 293250953317
parent 15216 924f7e38815e
child 15218 517f3a1dd5c2
fix u32 conversion sign
rust/fpnum/src/lib.rs
--- a/rust/fpnum/src/lib.rs	Thu Jul 04 17:59:37 2019 +0300
+++ b/rust/fpnum/src/lib.rs	Thu Jul 04 19:21:56 2019 +0300
@@ -117,7 +117,7 @@
 
     #[inline]
     const fn temp_i128(self) -> i128 {
-        ((self.value ^ self.sign_mask) as u128 as i128).wrapping_sub(self.sign_mask as i128)
+        ((self.value ^ self.sign_mask) as i128).wrapping_sub(self.sign_mask as i128)
     }
 }
 
@@ -135,7 +135,7 @@
     #[inline]
     fn from(n: u32) -> Self {
         Self {
-            sign_mask: NEGATIVE_MASK,
+            sign_mask: POSITIVE_MASK,
             value: (n as u64) << 32,
         }
     }