rust/fpnum/src/lib.rs
changeset 15217 293250953317
parent 15216 924f7e38815e
child 15218 517f3a1dd5c2
equal deleted inserted replaced
15216:924f7e38815e 15217:293250953317
   115         FPPoint::new(self, self)
   115         FPPoint::new(self, self)
   116     }
   116     }
   117 
   117 
   118     #[inline]
   118     #[inline]
   119     const fn temp_i128(self) -> i128 {
   119     const fn temp_i128(self) -> i128 {
   120         ((self.value ^ self.sign_mask) as u128 as i128).wrapping_sub(self.sign_mask as i128)
   120         ((self.value ^ self.sign_mask) as i128).wrapping_sub(self.sign_mask as i128)
   121     }
   121     }
   122 }
   122 }
   123 
   123 
   124 impl From<i32> for FPNum {
   124 impl From<i32> for FPNum {
   125     #[inline]
   125     #[inline]
   133 
   133 
   134 impl From<u32> for FPNum {
   134 impl From<u32> for FPNum {
   135     #[inline]
   135     #[inline]
   136     fn from(n: u32) -> Self {
   136     fn from(n: u32) -> Self {
   137         Self {
   137         Self {
   138             sign_mask: NEGATIVE_MASK,
   138             sign_mask: POSITIVE_MASK,
   139             value: (n as u64) << 32,
   139             value: (n as u64) << 32,
   140         }
   140         }
   141     }
   141     }
   142 }
   142 }
   143 
   143