add sin_pi_f16, cos_pi_f16, and sin_cos_pi_f16
[vector-math.git] / src / ieee754.rs
index 6f9fea7359f868e466a45ea84603a02c98a1c20a..3d70468a8e438490a836e6787e097412ad2a847d 100644 (file)
@@ -1,8 +1,4 @@
-use crate::{
-    f16::F16,
-    scalar::Scalar,
-    traits::{Float, Make},
-};
+use crate::f16::F16;
 
 mod sealed {
     use crate::f16::F16;
@@ -13,9 +9,9 @@ mod sealed {
     impl Sealed for f64 {}
 }
 
-pub trait FloatEncoding:
-    sealed::Sealed + Copy + 'static + Send + Sync + Float + Make<Context = Scalar>
-{
+pub trait FloatEncoding: sealed::Sealed + Copy + 'static + Send + Sync {
+    type BitsType;
+    type SignedBitsType;
     const EXPONENT_BIAS_UNSIGNED: Self::BitsType;
     const EXPONENT_BIAS_SIGNED: Self::SignedBitsType;
     const SIGN_FIELD_WIDTH: Self::BitsType;
@@ -37,11 +33,15 @@ pub trait FloatEncoding:
 macro_rules! impl_float_encoding {
     (
         impl FloatEncoding for $float:ident {
+            type BitsType = $bits_type:ident;
+            type SignedBitsType = $signed_bits_type:ident;
             const EXPONENT_FIELD_WIDTH: u32 = $exponent_field_width:literal;
             const MANTISSA_FIELD_WIDTH: u32 = $mantissa_field_width:literal;
         }
     ) => {
         impl FloatEncoding for $float {
+            type BitsType = $bits_type;
+            type SignedBitsType = $signed_bits_type;
             const EXPONENT_BIAS_UNSIGNED: Self::BitsType =
                 (1 << (Self::EXPONENT_FIELD_WIDTH - 1)) - 1;
             const EXPONENT_BIAS_SIGNED: Self::SignedBitsType = Self::EXPONENT_BIAS_UNSIGNED as _;
@@ -69,6 +69,8 @@ macro_rules! impl_float_encoding {
 
 impl_float_encoding! {
     impl FloatEncoding for F16 {
+        type BitsType = u16;
+        type SignedBitsType = i16;
         const EXPONENT_FIELD_WIDTH: u32 = 5;
         const MANTISSA_FIELD_WIDTH: u32 = 10;
     }
@@ -76,6 +78,8 @@ impl_float_encoding! {
 
 impl_float_encoding! {
     impl FloatEncoding for f32 {
+        type BitsType = u32;
+        type SignedBitsType = i32;
         const EXPONENT_FIELD_WIDTH: u32 = 8;
         const MANTISSA_FIELD_WIDTH: u32 = 23;
     }
@@ -83,6 +87,8 @@ impl_float_encoding! {
 
 impl_float_encoding! {
     impl FloatEncoding for f64 {
+        type BitsType = u64;
+        type SignedBitsType = i64;
         const EXPONENT_FIELD_WIDTH: u32 = 11;
         const MANTISSA_FIELD_WIDTH: u32 = 52;
     }