add copy_sign and genericify abs
[vector-math.git] / src / f16.rs
index 5253fef282e136c966950c2d3c4f536bc120fa0c..280d00d4231f751192b12a5d715cd26734318fa6 100644 (file)
@@ -204,6 +204,12 @@ impl F16 {
     pub fn abs(self) -> Self {
         f16_impl!(Self::from_bits(self.to_bits() & 0x7FFF), [])
     }
+    pub fn copysign(self, sign: Self) -> Self {
+        f16_impl!(
+            Self::from_bits((self.to_bits() & 0x7FFF) | (sign.to_bits() & 0x8000)),
+            [sign]
+        )
+    }
     pub fn trunc(self) -> Self {
         #[cfg(feature = "std")]
         return f32::from(self).trunc().to();