stdsimd bindings work!
[vector-math.git] / src / f16.rs
index 20ed902ff6e0afc542f93a869bb40707c2d6f47f..5bc1119443466e949640876b70e54c6bf15f24d6 100644 (file)
@@ -14,6 +14,12 @@ type F16Impl = u16;
 #[repr(transparent)]
 pub struct F16(F16Impl);
 
+#[cfg(not(feature = "f16"))]
+#[track_caller]
+pub(crate) fn panic_f16_feature_disabled() -> ! {
+    panic!("f16 feature is not enabled")
+}
+
 #[cfg(feature = "f16")]
 macro_rules! f16_impl {
     ($v:expr, [$($vars:ident),*]) => {
@@ -26,11 +32,17 @@ macro_rules! f16_impl {
     ($v:expr, [$($vars:ident),*]) => {
         {
             $(let _ = $vars;)*
-            panic!("f16 feature is not enabled")
+            panic_f16_feature_disabled()
         }
     };
 }
 
+impl Default for F16 {
+    fn default() -> Self {
+        f16_impl!(F16(F16Impl::default()), [])
+    }
+}
+
 impl From<F16Impl> for F16 {
     fn from(v: F16Impl) -> Self {
         F16(v)
@@ -161,8 +173,10 @@ impl_bin_op_using_f32! {
     Rem, rem, RemAssign, rem_assign;
 }
 
-impl Float<u32> for F16 {
+impl Float for F16 {
+    type FloatEncoding = F16;
     type BitsType = u16;
+    type SignedBitsType = i16;
 
     fn abs(self) -> Self {
         f16_impl!(Self::from_bits(self.to_bits() & 0x7FFF), [])