add sqrt_fast_f16/f32/f64
[vector-math.git] / src / traits.rs
index e923e1a682ee9170b6f8cfdca7a0ca73470337a0..67daa228c82e8ecc8e293f0d99004c307e788fbd 100644 (file)
@@ -242,6 +242,14 @@ pub trait Float:
             (sign_field << sign_shift) | (exponent_field << exponent_shift) | mantissa_field,
         )
     }
+    fn with_exponent_field(self, exponent_field: Self::BitsType) -> Self {
+        let exponent_shift = self.ctx().make(Self::PrimFloat::EXPONENT_FIELD_SHIFT);
+        let not_exponent_mask = self.ctx().make(!Self::PrimFloat::EXPONENT_FIELD_MASK);
+        Self::from_bits((self.to_bits() & not_exponent_mask) | (exponent_field << exponent_shift))
+    }
+    fn with_exponent_unbiased(self, exponent: Self::SignedBitsType) -> Self {
+        self.with_exponent_field(Self::add_exponent_bias(exponent))
+    }
     fn sub_exponent_bias(exponent_field: Self::BitsType) -> Self::SignedBitsType {
         Self::SignedBitsType::cvt_from(exponent_field)
             - exponent_field