about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-06-09 14:17:28 +0200
committerRalf Jung <post@ralfj.de>2025-06-09 14:17:28 +0200
commit20cf8ca3f7ac0213f64f89f332793ed8d1a04903 (patch)
treeee1e31c5b6ef5b9760bafc9841374191e693336f
parentb6685d748fe4668571c05ba338f61520db6dacc9 (diff)
downloadrust-20cf8ca3f7ac0213f64f89f332793ed8d1a04903.tar.gz
rust-20cf8ca3f7ac0213f64f89f332793ed8d1a04903.zip
float tests: use assert_biteq in more places
-rw-r--r--library/coretests/tests/floats/f128.rs2
-rw-r--r--library/coretests/tests/floats/f16.rs2
-rw-r--r--library/coretests/tests/floats/f32.rs2
-rw-r--r--library/coretests/tests/floats/f64.rs2
-rw-r--r--library/coretests/tests/floats/mod.rs431
5 files changed, 224 insertions, 215 deletions
diff --git a/library/coretests/tests/floats/f128.rs b/library/coretests/tests/floats/f128.rs
index 01770f119df..ffa05715b2d 100644
--- a/library/coretests/tests/floats/f128.rs
+++ b/library/coretests/tests/floats/f128.rs
@@ -5,6 +5,8 @@ use core::ops::{Add, Div, Mul, Sub};
 use std::f128::consts;
 use std::num::FpCategory as Fp;
 
+use super::{assert_approx_eq, assert_biteq};
+
 // Note these tolerances make sense around zero, but not for more extreme exponents.
 
 /// Default tolerances. Works for values that should be near precise but not exact. Roughly
diff --git a/library/coretests/tests/floats/f16.rs b/library/coretests/tests/floats/f16.rs
index 4797573f7d0..7e8ce99dbe0 100644
--- a/library/coretests/tests/floats/f16.rs
+++ b/library/coretests/tests/floats/f16.rs
@@ -4,6 +4,8 @@
 use std::f16::consts;
 use std::num::FpCategory as Fp;
 
+use super::{assert_approx_eq, assert_biteq};
+
 /// Tolerance for results on the order of 10.0e-2
 #[allow(unused)]
 const TOL_N2: f16 = 0.0001;
diff --git a/library/coretests/tests/floats/f32.rs b/library/coretests/tests/floats/f32.rs
index 4e6509ead2b..460aecaac64 100644
--- a/library/coretests/tests/floats/f32.rs
+++ b/library/coretests/tests/floats/f32.rs
@@ -2,6 +2,8 @@ use core::f32;
 use core::f32::consts;
 use core::num::FpCategory as Fp;
 
+use super::{assert_approx_eq, assert_biteq};
+
 /// Smallest number
 const TINY_BITS: u32 = 0x1;
 
diff --git a/library/coretests/tests/floats/f64.rs b/library/coretests/tests/floats/f64.rs
index 74202a37409..1dfce22c14a 100644
--- a/library/coretests/tests/floats/f64.rs
+++ b/library/coretests/tests/floats/f64.rs
@@ -2,6 +2,8 @@ use core::f64;
 use core::f64::consts;
 use core::num::FpCategory as Fp;
 
+use super::{assert_approx_eq, assert_biteq};
+
 /// Smallest number
 const TINY_BITS: u64 = 0x1;
 
diff --git a/library/coretests/tests/floats/mod.rs b/library/coretests/tests/floats/mod.rs
index f9b6c85f871..a2b0d6caf13 100644
--- a/library/coretests/tests/floats/mod.rs
+++ b/library/coretests/tests/floats/mod.rs
@@ -2,7 +2,7 @@ use std::fmt;
 use std::ops::{Add, Div, Mul, Rem, Sub};
 
 /// Verify that floats are within a tolerance of each other, 1.0e-6 by default.
-macro_rules! assert_approx_eq {
+macro_rules! assert_approx_eq_ {
     ($a:expr, $b:expr) => {{ assert_approx_eq!($a, $b, 1.0e-6) }};
     ($a:expr, $b:expr, $lim:expr) => {{
         let (a, b) = (&$a, &$b);
@@ -14,10 +14,11 @@ macro_rules! assert_approx_eq {
         );
     }};
 }
+pub(crate) use assert_approx_eq_ as assert_approx_eq;
 
 /// Verify that floats have the same bitwise representation. Used to avoid the default `0.0 == -0.0`
 /// behavior, as well as to ensure exact NaN bitpatterns.
-macro_rules! assert_biteq {
+macro_rules! assert_biteq_ {
     (@inner $left:expr, $right:expr, $msg_sep:literal, $($tt:tt)*) => {{
         let l = $left;
         let r = $right;
@@ -41,17 +42,19 @@ macro_rules! assert_biteq {
         if !l.is_nan() && !r.is_nan() {
             // Also check that standard equality holds, since most tests use `assert_biteq` rather
             // than `assert_eq`.
-            assert_eq!(l, r)
+            assert_eq!(l, r);
         }
     }};
     ($left:expr, $right:expr , $($tt:tt)*) => {
-        assert_biteq!(@inner $left, $right, "\n", $($tt)*)
+        assert_biteq_!(@inner $left, $right, "\n", $($tt)*)
     };
     ($left:expr, $right:expr $(,)?) => {
-        assert_biteq!(@inner $left, $right, "", "")
+        assert_biteq_!(@inner $left, $right, "", "")
     };
 }
+pub(crate) use assert_biteq_ as assert_biteq;
 
+#[allow(unused)]
 mod const_asserts {
     // Shadow some assert implementations that would otherwise not compile in a const-context.
     // Every macro added here also needs to be added in the `float_test!` macro below.
@@ -63,8 +66,43 @@ mod const_asserts {
             std::assert!($left == $right, $($arg)+)
         };
     }
-
     pub(crate) use assert_eq;
+
+    macro_rules! assert_biteq {
+        (@inner $left:expr, $right:expr, $msg_sep:literal, $($tt:tt)*) => {{
+            let l = $left;
+            let r = $right;
+
+            // Hack to coerce left and right to the same type
+            let mut _eq_ty = l;
+            _eq_ty = r;
+
+            assert!(l.to_bits() == r.to_bits());
+
+            if !l.is_nan() && !r.is_nan() {
+                // Also check that standard equality holds, since most tests use `assert_biteq` rather
+                // than `assert_eq`.
+                assert!(l == r);
+            }
+        }};
+        ($left:expr, $right:expr , $($tt:tt)*) => {
+            assert_biteq!(@inner $left, $right, "\n", $($tt)*)
+        };
+        ($left:expr, $right:expr $(,)?) => {
+            assert_biteq!(@inner $left, $right, "", "")
+        };
+    }
+    pub(crate) use assert_biteq;
+
+    macro_rules! assert_approx_eq {
+        ($a:expr, $b:expr) => {{ assert_approx_eq!($a, $b, 1.0e-6) }};
+        ($a:expr, $b:expr, $lim:expr) => {{
+            let (a, b) = (&$a, &$b);
+            let diff = (*a - *b).abs();
+            assert!(diff <= $lim);
+        }};
+    }
+    pub(crate) use assert_approx_eq;
 }
 
 /// Generate float tests for all our float types, for compile-time and run-time behavior.
@@ -101,6 +139,8 @@ macro_rules! float_test {
         test<$fty:ident> $test:block
     ) => {
         mod $name {
+            use super::*;
+
             #[test]
             $( $( #[$f16_meta] )+ )?
             fn test_f16() {
@@ -131,7 +171,8 @@ macro_rules! float_test {
 
             $( $( #[$const_meta] )+ )?
             mod const_ {
-                use $crate::floats::const_asserts::assert_eq;
+                #[allow(unused)]
+                use $crate::floats::const_asserts::{assert_eq, assert_biteq, assert_approx_eq};
 
                 #[test]
                 $( $( #[$f16_const_meta] )+ )?
@@ -196,29 +237,25 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).min(0.0), 0.0);
-        assert!((0.0 as Float).min(0.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).min(-0.0), -0.0);
-        assert!((-0.0 as Float).min(-0.0).is_sign_negative());
-        assert_eq!((9.0 as Float).min(9.0), 9.0);
-        assert_eq!((-9.0 as Float).min(0.0), -9.0);
-        assert_eq!((0.0 as Float).min(9.0), 0.0);
-        assert!((0.0 as Float).min(9.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).min(9.0), -0.0);
-        assert!((-0.0 as Float).min(9.0).is_sign_negative());
-        assert_eq!((-0.0 as Float).min(-9.0), -9.0);
-        assert_eq!(Float::INFINITY.min(9.0), 9.0);
-        assert_eq!((9.0 as Float).min(Float::INFINITY), 9.0);
-        assert_eq!(Float::INFINITY.min(-9.0), -9.0);
-        assert_eq!((-9.0 as Float).min(Float::INFINITY), -9.0);
-        assert_eq!(Float::NEG_INFINITY.min(9.0), Float::NEG_INFINITY);
-        assert_eq!((9.0 as Float).min(Float::NEG_INFINITY), Float::NEG_INFINITY);
-        assert_eq!(Float::NEG_INFINITY.min(-9.0), Float::NEG_INFINITY);
-        assert_eq!((-9.0 as Float).min(Float::NEG_INFINITY), Float::NEG_INFINITY);
-        assert_eq!(Float::NAN.min(9.0), 9.0);
-        assert_eq!(Float::NAN.min(-9.0), -9.0);
-        assert_eq!((9.0 as Float).min(Float::NAN), 9.0);
-        assert_eq!((-9.0 as Float).min(Float::NAN), -9.0);
+        assert_biteq!((0.0 as Float).min(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).min(-0.0), -0.0);
+        assert_biteq!((9.0 as Float).min(9.0), 9.0);
+        assert_biteq!((-9.0 as Float).min(0.0), -9.0);
+        assert_biteq!((0.0 as Float).min(9.0), 0.0);
+        assert_biteq!((-0.0 as Float).min(9.0), -0.0);
+        assert_biteq!((-0.0 as Float).min(-9.0), -9.0);
+        assert_biteq!(Float::INFINITY.min(9.0), 9.0);
+        assert_biteq!((9.0 as Float).min(Float::INFINITY), 9.0);
+        assert_biteq!(Float::INFINITY.min(-9.0), -9.0);
+        assert_biteq!((-9.0 as Float).min(Float::INFINITY), -9.0);
+        assert_biteq!(Float::NEG_INFINITY.min(9.0), Float::NEG_INFINITY);
+        assert_biteq!((9.0 as Float).min(Float::NEG_INFINITY), Float::NEG_INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.min(-9.0), Float::NEG_INFINITY);
+        assert_biteq!((-9.0 as Float).min(Float::NEG_INFINITY), Float::NEG_INFINITY);
+        assert_biteq!(Float::NAN.min(9.0), 9.0);
+        assert_biteq!(Float::NAN.min(-9.0), -9.0);
+        assert_biteq!((9.0 as Float).min(Float::NAN), 9.0);
+        assert_biteq!((-9.0 as Float).min(Float::NAN), -9.0);
         assert!(Float::NAN.min(Float::NAN).is_nan());
     }
 }
@@ -230,32 +267,26 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).max(0.0), 0.0);
-        assert!((0.0 as Float).max(0.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).max(-0.0), -0.0);
-        assert!((-0.0 as Float).max(-0.0).is_sign_negative());
-        assert_eq!((9.0 as Float).max(9.0), 9.0);
-        assert_eq!((-9.0 as Float).max(0.0), 0.0);
-        assert!((-9.0 as Float).max(0.0).is_sign_positive());
-        assert_eq!((-9.0 as Float).max(-0.0), -0.0);
-        assert!((-9.0 as Float).max(-0.0).is_sign_negative());
-        assert_eq!((0.0 as Float).max(9.0), 9.0);
-        assert_eq!((0.0 as Float).max(-9.0), 0.0);
-        assert!((0.0 as Float).max(-9.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).max(-9.0), -0.0);
-        assert!((-0.0 as Float).max(-9.0).is_sign_negative());
-        assert_eq!(Float::INFINITY.max(9.0), Float::INFINITY);
-        assert_eq!((9.0 as Float).max(Float::INFINITY), Float::INFINITY);
-        assert_eq!(Float::INFINITY.max(-9.0), Float::INFINITY);
-        assert_eq!((-9.0 as Float).max(Float::INFINITY), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.max(9.0), 9.0);
-        assert_eq!((9.0 as Float).max(Float::NEG_INFINITY), 9.0);
-        assert_eq!(Float::NEG_INFINITY.max(-9.0), -9.0);
-        assert_eq!((-9.0 as Float).max(Float::NEG_INFINITY), -9.0);
-        assert_eq!(Float::NAN.max(9.0), 9.0);
-        assert_eq!(Float::NAN.max(-9.0), -9.0);
-        assert_eq!((9.0 as Float).max(Float::NAN), 9.0);
-        assert_eq!((-9.0 as Float).max(Float::NAN), -9.0);
+        assert_biteq!((0.0 as Float).max(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).max(-0.0), -0.0);
+        assert_biteq!((9.0 as Float).max(9.0), 9.0);
+        assert_biteq!((-9.0 as Float).max(0.0), 0.0);
+        assert_biteq!((-9.0 as Float).max(-0.0), -0.0);
+        assert_biteq!((0.0 as Float).max(9.0), 9.0);
+        assert_biteq!((0.0 as Float).max(-9.0), 0.0);
+        assert_biteq!((-0.0 as Float).max(-9.0), -0.0);
+        assert_biteq!(Float::INFINITY.max(9.0), Float::INFINITY);
+        assert_biteq!((9.0 as Float).max(Float::INFINITY), Float::INFINITY);
+        assert_biteq!(Float::INFINITY.max(-9.0), Float::INFINITY);
+        assert_biteq!((-9.0 as Float).max(Float::INFINITY), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.max(9.0), 9.0);
+        assert_biteq!((9.0 as Float).max(Float::NEG_INFINITY), 9.0);
+        assert_biteq!(Float::NEG_INFINITY.max(-9.0), -9.0);
+        assert_biteq!((-9.0 as Float).max(Float::NEG_INFINITY), -9.0);
+        assert_biteq!(Float::NAN.max(9.0), 9.0);
+        assert_biteq!(Float::NAN.max(-9.0), -9.0);
+        assert_biteq!((9.0 as Float).max(Float::NAN), 9.0);
+        assert_biteq!((-9.0 as Float).max(Float::NAN), -9.0);
         assert!(Float::NAN.max(Float::NAN).is_nan());
     }
 }
@@ -267,27 +298,22 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).minimum(0.0), 0.0);
-        assert!((0.0 as Float).minimum(0.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).minimum(0.0), -0.0);
-        assert!((-0.0 as Float).minimum(0.0).is_sign_negative());
-        assert_eq!((-0.0 as Float).minimum(-0.0), -0.0);
-        assert!((-0.0 as Float).minimum(-0.0).is_sign_negative());
-        assert_eq!((9.0 as Float).minimum(9.0), 9.0);
-        assert_eq!((-9.0 as Float).minimum(0.0), -9.0);
-        assert_eq!((0.0 as Float).minimum(9.0), 0.0);
-        assert!((0.0 as Float).minimum(9.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).minimum(9.0), -0.0);
-        assert!((-0.0 as Float).minimum(9.0).is_sign_negative());
-        assert_eq!((-0.0 as Float).minimum(-9.0), -9.0);
-        assert_eq!(Float::INFINITY.minimum(9.0), 9.0);
-        assert_eq!((9.0 as Float).minimum(Float::INFINITY), 9.0);
-        assert_eq!(Float::INFINITY.minimum(-9.0), -9.0);
-        assert_eq!((-9.0 as Float).minimum(Float::INFINITY), -9.0);
-        assert_eq!(Float::NEG_INFINITY.minimum(9.0), Float::NEG_INFINITY);
-        assert_eq!((9.0 as Float).minimum(Float::NEG_INFINITY), Float::NEG_INFINITY);
-        assert_eq!(Float::NEG_INFINITY.minimum(-9.0), Float::NEG_INFINITY);
-        assert_eq!((-9.0 as Float).minimum(Float::NEG_INFINITY), Float::NEG_INFINITY);
+        assert_biteq!((0.0 as Float).minimum(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).minimum(0.0), -0.0);
+        assert_biteq!((-0.0 as Float).minimum(-0.0), -0.0);
+        assert_biteq!((9.0 as Float).minimum(9.0), 9.0);
+        assert_biteq!((-9.0 as Float).minimum(0.0), -9.0);
+        assert_biteq!((0.0 as Float).minimum(9.0), 0.0);
+        assert_biteq!((-0.0 as Float).minimum(9.0), -0.0);
+        assert_biteq!((-0.0 as Float).minimum(-9.0), -9.0);
+        assert_biteq!(Float::INFINITY.minimum(9.0), 9.0);
+        assert_biteq!((9.0 as Float).minimum(Float::INFINITY), 9.0);
+        assert_biteq!(Float::INFINITY.minimum(-9.0), -9.0);
+        assert_biteq!((-9.0 as Float).minimum(Float::INFINITY), -9.0);
+        assert_biteq!(Float::NEG_INFINITY.minimum(9.0), Float::NEG_INFINITY);
+        assert_biteq!((9.0 as Float).minimum(Float::NEG_INFINITY), Float::NEG_INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.minimum(-9.0), Float::NEG_INFINITY);
+        assert_biteq!((-9.0 as Float).minimum(Float::NEG_INFINITY), Float::NEG_INFINITY);
         assert!(Float::NAN.minimum(9.0).is_nan());
         assert!(Float::NAN.minimum(-9.0).is_nan());
         assert!((9.0 as Float).minimum(Float::NAN).is_nan());
@@ -303,30 +329,23 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).maximum(0.0), 0.0);
-        assert!((0.0 as Float).maximum(0.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).maximum(0.0), 0.0);
-        assert!((-0.0 as Float).maximum(0.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).maximum(-0.0), -0.0);
-        assert!((-0.0 as Float).maximum(-0.0).is_sign_negative());
-        assert_eq!((9.0 as Float).maximum(9.0), 9.0);
-        assert_eq!((-9.0 as Float).maximum(0.0), 0.0);
-        assert!((-9.0 as Float).maximum(0.0).is_sign_positive());
-        assert_eq!((-9.0 as Float).maximum(-0.0), -0.0);
-        assert!((-9.0 as Float).maximum(-0.0).is_sign_negative());
-        assert_eq!((0.0 as Float).maximum(9.0), 9.0);
-        assert_eq!((0.0 as Float).maximum(-9.0), 0.0);
-        assert!((0.0 as Float).maximum(-9.0).is_sign_positive());
-        assert_eq!((-0.0 as Float).maximum(-9.0), -0.0);
-        assert!((-0.0 as Float).maximum(-9.0).is_sign_negative());
-        assert_eq!(Float::INFINITY.maximum(9.0), Float::INFINITY);
-        assert_eq!((9.0 as Float).maximum(Float::INFINITY), Float::INFINITY);
-        assert_eq!(Float::INFINITY.maximum(-9.0), Float::INFINITY);
-        assert_eq!((-9.0 as Float).maximum(Float::INFINITY), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.maximum(9.0), 9.0);
-        assert_eq!((9.0 as Float).maximum(Float::NEG_INFINITY), 9.0);
-        assert_eq!(Float::NEG_INFINITY.maximum(-9.0), -9.0);
-        assert_eq!((-9.0 as Float).maximum(Float::NEG_INFINITY), -9.0);
+        assert_biteq!((0.0 as Float).maximum(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).maximum(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).maximum(-0.0), -0.0);
+        assert_biteq!((9.0 as Float).maximum(9.0), 9.0);
+        assert_biteq!((-9.0 as Float).maximum(0.0), 0.0);
+        assert_biteq!((-9.0 as Float).maximum(-0.0), -0.0);
+        assert_biteq!((0.0 as Float).maximum(9.0), 9.0);
+        assert_biteq!((0.0 as Float).maximum(-9.0), 0.0);
+        assert_biteq!((-0.0 as Float).maximum(-9.0), -0.0);
+        assert_biteq!(Float::INFINITY.maximum(9.0), Float::INFINITY);
+        assert_biteq!((9.0 as Float).maximum(Float::INFINITY), Float::INFINITY);
+        assert_biteq!(Float::INFINITY.maximum(-9.0), Float::INFINITY);
+        assert_biteq!((-9.0 as Float).maximum(Float::INFINITY), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.maximum(9.0), 9.0);
+        assert_biteq!((9.0 as Float).maximum(Float::NEG_INFINITY), 9.0);
+        assert_biteq!(Float::NEG_INFINITY.maximum(-9.0), -9.0);
+        assert_biteq!((-9.0 as Float).maximum(Float::NEG_INFINITY), -9.0);
         assert!(Float::NAN.maximum(9.0).is_nan());
         assert!(Float::NAN.maximum(-9.0).is_nan());
         assert!((9.0 as Float).maximum(Float::NAN).is_nan());
@@ -342,38 +361,38 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.5 as Float).midpoint(0.5), 0.5);
-        assert_eq!((0.5 as Float).midpoint(2.5), 1.5);
-        assert_eq!((3.0 as Float).midpoint(4.0), 3.5);
-        assert_eq!((-3.0 as Float).midpoint(4.0), 0.5);
-        assert_eq!((3.0 as Float).midpoint(-4.0), -0.5);
-        assert_eq!((-3.0 as Float).midpoint(-4.0), -3.5);
-        assert_eq!((0.0 as Float).midpoint(0.0), 0.0);
-        assert_eq!((-0.0 as Float).midpoint(-0.0), -0.0);
-        assert_eq!((-5.0 as Float).midpoint(5.0), 0.0);
-        assert_eq!(Float::MAX.midpoint(Float::MIN), 0.0);
-        assert_eq!(Float::MIN.midpoint(Float::MAX), -0.0);
-        assert_eq!(Float::MAX.midpoint(Float::MIN_POSITIVE), Float::MAX / 2.);
-        assert_eq!((-Float::MAX).midpoint(Float::MIN_POSITIVE), -Float::MAX / 2.);
-        assert_eq!(Float::MAX.midpoint(-Float::MIN_POSITIVE), Float::MAX / 2.);
-        assert_eq!((-Float::MAX).midpoint(-Float::MIN_POSITIVE), -Float::MAX / 2.);
-        assert_eq!((Float::MIN_POSITIVE).midpoint(Float::MAX), Float::MAX / 2.);
-        assert_eq!((Float::MIN_POSITIVE).midpoint(-Float::MAX), -Float::MAX / 2.);
-        assert_eq!((-Float::MIN_POSITIVE).midpoint(Float::MAX), Float::MAX / 2.);
-        assert_eq!((-Float::MIN_POSITIVE).midpoint(-Float::MAX), -Float::MAX / 2.);
-        assert_eq!(Float::MAX.midpoint(Float::MAX), Float::MAX);
-        assert_eq!(
+        assert_biteq!((0.5 as Float).midpoint(0.5), 0.5);
+        assert_biteq!((0.5 as Float).midpoint(2.5), 1.5);
+        assert_biteq!((3.0 as Float).midpoint(4.0), 3.5);
+        assert_biteq!((-3.0 as Float).midpoint(4.0), 0.5);
+        assert_biteq!((3.0 as Float).midpoint(-4.0), -0.5);
+        assert_biteq!((-3.0 as Float).midpoint(-4.0), -3.5);
+        assert_biteq!((0.0 as Float).midpoint(0.0), 0.0);
+        assert_biteq!((-0.0 as Float).midpoint(-0.0), -0.0);
+        assert_biteq!((-5.0 as Float).midpoint(5.0), 0.0);
+        assert_biteq!(Float::MAX.midpoint(Float::MIN), 0.0);
+        assert_biteq!(Float::MIN.midpoint(Float::MAX), 0.0);
+        assert_biteq!(Float::MAX.midpoint(Float::MIN_POSITIVE), Float::MAX / 2.);
+        assert_biteq!((-Float::MAX).midpoint(Float::MIN_POSITIVE), -Float::MAX / 2.);
+        assert_biteq!(Float::MAX.midpoint(-Float::MIN_POSITIVE), Float::MAX / 2.);
+        assert_biteq!((-Float::MAX).midpoint(-Float::MIN_POSITIVE), -Float::MAX / 2.);
+        assert_biteq!((Float::MIN_POSITIVE).midpoint(Float::MAX), Float::MAX / 2.);
+        assert_biteq!((Float::MIN_POSITIVE).midpoint(-Float::MAX), -Float::MAX / 2.);
+        assert_biteq!((-Float::MIN_POSITIVE).midpoint(Float::MAX), Float::MAX / 2.);
+        assert_biteq!((-Float::MIN_POSITIVE).midpoint(-Float::MAX), -Float::MAX / 2.);
+        assert_biteq!(Float::MAX.midpoint(Float::MAX), Float::MAX);
+        assert_biteq!(
             (Float::MIN_POSITIVE).midpoint(Float::MIN_POSITIVE),
             Float::MIN_POSITIVE
         );
-        assert_eq!(
+        assert_biteq!(
             (-Float::MIN_POSITIVE).midpoint(-Float::MIN_POSITIVE),
             -Float::MIN_POSITIVE
         );
-        assert_eq!(Float::MAX.midpoint(5.0), Float::MAX / 2.0 + 2.5);
-        assert_eq!(Float::MAX.midpoint(-5.0), Float::MAX / 2.0 - 2.5);
-        assert_eq!(Float::INFINITY.midpoint(Float::INFINITY), Float::INFINITY);
-        assert_eq!(
+        assert_biteq!(Float::MAX.midpoint(5.0), Float::MAX / 2.0 + 2.5);
+        assert_biteq!(Float::MAX.midpoint(-5.0), Float::MAX / 2.0 - 2.5);
+        assert_biteq!(Float::INFINITY.midpoint(Float::INFINITY), Float::INFINITY);
+        assert_biteq!(
             Float::NEG_INFINITY.midpoint(Float::NEG_INFINITY),
             Float::NEG_INFINITY
         );
@@ -410,7 +429,7 @@ float_test! {
                 let naive = (large + small) / 2.0;
                 let midpoint = large.midpoint(small);
 
-                assert_eq!(naive, midpoint);
+                assert_biteq!(naive, midpoint);
             }
         }
     }
@@ -423,10 +442,10 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((-1.0 as Float).abs(), 1.0);
-        assert_eq!((1.0 as Float).abs(), 1.0);
-        assert_eq!(Float::NEG_INFINITY.abs(), Float::INFINITY);
-        assert_eq!(Float::INFINITY.abs(), Float::INFINITY);
+        assert_biteq!((-1.0 as Float).abs(), 1.0);
+        assert_biteq!((1.0 as Float).abs(), 1.0);
+        assert_biteq!(Float::NEG_INFINITY.abs(), Float::INFINITY);
+        assert_biteq!(Float::INFINITY.abs(), Float::INFINITY);
     }
 }
 
@@ -437,10 +456,10 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((1.0 as Float).copysign(-2.0), -1.0);
-        assert_eq!((-1.0 as Float).copysign(2.0), 1.0);
-        assert_eq!(Float::INFINITY.copysign(-0.0), Float::NEG_INFINITY);
-        assert_eq!(Float::NEG_INFINITY.copysign(0.0), Float::INFINITY);
+        assert_biteq!((1.0 as Float).copysign(-2.0), -1.0);
+        assert_biteq!((-1.0 as Float).copysign(2.0), 1.0);
+        assert_biteq!(Float::INFINITY.copysign(-0.0), Float::NEG_INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.copysign(0.0), Float::INFINITY);
     }
 }
 
@@ -453,7 +472,7 @@ float_test! {
     },
     test<Float> {
         assert!(Float::INFINITY.rem_euclid(42.0 as Float).is_nan());
-        assert_eq!((42.0 as Float).rem_euclid(Float::INFINITY), (42.0 as Float));
+        assert_biteq!((42.0 as Float).rem_euclid(Float::INFINITY), 42.0 as Float);
         assert!((42.0 as Float).rem_euclid(Float::NAN).is_nan());
         assert!(Float::INFINITY.rem_euclid(Float::INFINITY).is_nan());
         assert!(Float::INFINITY.rem_euclid(Float::NAN).is_nan());
@@ -469,7 +488,7 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((42.0 as Float).div_euclid(Float::INFINITY), 0.0);
+        assert_biteq!((42.0 as Float).div_euclid(Float::INFINITY), 0.0);
         assert!((42.0 as Float).div_euclid(Float::NAN).is_nan());
         assert!(Float::INFINITY.div_euclid(Float::INFINITY).is_nan());
         assert!(Float::INFINITY.div_euclid(Float::NAN).is_nan());
@@ -484,20 +503,18 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).floor(), 0.0);
-        assert!((0.0 as Float).floor().is_sign_positive());
-        assert_eq!((-0.0 as Float).floor(), -0.0);
-        assert!((-0.0 as Float).floor().is_sign_negative());
-        assert_eq!((0.5 as Float).floor(), 0.0);
-        assert_eq!((-0.5 as Float).floor(), -1.0);
-        assert_eq!((1.5 as Float).floor(), 1.0);
-        assert_eq!(Float::MAX.floor(), Float::MAX);
-        assert_eq!(Float::MIN.floor(), Float::MIN);
-        assert_eq!(Float::MIN_POSITIVE.floor(), 0.0);
-        assert_eq!((-Float::MIN_POSITIVE).floor(), -1.0);
+        assert_biteq!((0.0 as Float).floor(), 0.0);
+        assert_biteq!((-0.0 as Float).floor(), -0.0);
+        assert_biteq!((0.5 as Float).floor(), 0.0);
+        assert_biteq!((-0.5 as Float).floor(), -1.0);
+        assert_biteq!((1.5 as Float).floor(), 1.0);
+        assert_biteq!(Float::MAX.floor(), Float::MAX);
+        assert_biteq!(Float::MIN.floor(), Float::MIN);
+        assert_biteq!(Float::MIN_POSITIVE.floor(), 0.0);
+        assert_biteq!((-Float::MIN_POSITIVE).floor(), -1.0);
         assert!(Float::NAN.floor().is_nan());
-        assert_eq!(Float::INFINITY.floor(), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.floor(), Float::NEG_INFINITY);
+        assert_biteq!(Float::INFINITY.floor(), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.floor(), Float::NEG_INFINITY);
     }
 }
 
@@ -508,19 +525,17 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).ceil(), 0.0);
-        assert!((0.0 as Float).ceil().is_sign_positive());
-        assert_eq!((-0.0 as Float).ceil(), 0.0);
-        assert!((-0.0 as Float).ceil().is_sign_negative());
-        assert_eq!((0.5 as Float).ceil(), 1.0);
-        assert_eq!((-0.5 as Float).ceil(), 0.0);
-        assert_eq!(Float::MAX.ceil(), Float::MAX);
-        assert_eq!(Float::MIN.ceil(), Float::MIN);
-        assert_eq!(Float::MIN_POSITIVE.ceil(), 1.0);
-        assert_eq!((-Float::MIN_POSITIVE).ceil(), 0.0);
+        assert_biteq!((0.0 as Float).ceil(), 0.0);
+        assert_biteq!((-0.0 as Float).ceil(), -0.0);
+        assert_biteq!((0.5 as Float).ceil(), 1.0);
+        assert_biteq!((-0.5 as Float).ceil(), -0.0);
+        assert_biteq!(Float::MAX.ceil(), Float::MAX);
+        assert_biteq!(Float::MIN.ceil(), Float::MIN);
+        assert_biteq!(Float::MIN_POSITIVE.ceil(), 1.0);
+        assert_biteq!((-Float::MIN_POSITIVE).ceil(), -0.0);
         assert!(Float::NAN.ceil().is_nan());
-        assert_eq!(Float::INFINITY.ceil(), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.ceil(), Float::NEG_INFINITY);
+        assert_biteq!(Float::INFINITY.ceil(), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.ceil(), Float::NEG_INFINITY);
     }
 }
 
@@ -531,19 +546,17 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).round(), 0.0);
-        assert!((0.0 as Float).round().is_sign_positive());
-        assert_eq!((-0.0 as Float).round(), -0.0);
-        assert!((-0.0 as Float).round().is_sign_negative());
-        assert_eq!((0.5 as Float).round(), 1.0);
-        assert_eq!((-0.5 as Float).round(), -1.0);
-        assert_eq!(Float::MAX.round(), Float::MAX);
-        assert_eq!(Float::MIN.round(), Float::MIN);
-        assert_eq!(Float::MIN_POSITIVE.round(), 0.0);
-        assert_eq!((-Float::MIN_POSITIVE).round(), 0.0);
+        assert_biteq!((0.0 as Float).round(), 0.0);
+        assert_biteq!((-0.0 as Float).round(), -0.0);
+        assert_biteq!((0.5 as Float).round(), 1.0);
+        assert_biteq!((-0.5 as Float).round(), -1.0);
+        assert_biteq!(Float::MAX.round(), Float::MAX);
+        assert_biteq!(Float::MIN.round(), Float::MIN);
+        assert_biteq!(Float::MIN_POSITIVE.round(), 0.0);
+        assert_biteq!((-Float::MIN_POSITIVE).round(), -0.0);
         assert!(Float::NAN.round().is_nan());
-        assert_eq!(Float::INFINITY.round(), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.round(), Float::NEG_INFINITY);
+        assert_biteq!(Float::INFINITY.round(), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.round(), Float::NEG_INFINITY);
     }
 }
 
@@ -554,21 +567,17 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).round_ties_even(), 0.0);
-        assert!((0.0 as Float).round_ties_even().is_sign_positive());
-        assert_eq!((-0.0 as Float).round_ties_even(), -0.0);
-        assert!((-0.0 as Float).round_ties_even().is_sign_negative());
-        assert_eq!((0.5 as Float).round_ties_even(), 0.0);
-        assert!((0.5 as Float).round_ties_even().is_sign_positive());
-        assert_eq!((-0.5 as Float).round_ties_even(), -0.0);
-        assert!((-0.5 as Float).round_ties_even().is_sign_negative());
-        assert_eq!(Float::MAX.round_ties_even(), Float::MAX);
-        assert_eq!(Float::MIN.round_ties_even(), Float::MIN);
-        assert_eq!(Float::MIN_POSITIVE.round_ties_even(), 0.0);
-        assert_eq!((-Float::MIN_POSITIVE).round_ties_even(), 0.0);
+        assert_biteq!((0.0 as Float).round_ties_even(), 0.0);
+        assert_biteq!((-0.0 as Float).round_ties_even(), -0.0);
+        assert_biteq!((0.5 as Float).round_ties_even(), 0.0);
+        assert_biteq!((-0.5 as Float).round_ties_even(), -0.0);
+        assert_biteq!(Float::MAX.round_ties_even(), Float::MAX);
+        assert_biteq!(Float::MIN.round_ties_even(), Float::MIN);
+        assert_biteq!(Float::MIN_POSITIVE.round_ties_even(), 0.0);
+        assert_biteq!((-Float::MIN_POSITIVE).round_ties_even(), -0.0);
         assert!(Float::NAN.round_ties_even().is_nan());
-        assert_eq!(Float::INFINITY.round_ties_even(), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.round_ties_even(), Float::NEG_INFINITY);
+        assert_biteq!(Float::INFINITY.round_ties_even(), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.round_ties_even(), Float::NEG_INFINITY);
     }
 }
 
@@ -579,21 +588,17 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).trunc(), 0.0);
-        assert!((0.0 as Float).trunc().is_sign_positive());
-        assert_eq!((-0.0 as Float).trunc(), -0.0);
-        assert!((-0.0 as Float).trunc().is_sign_negative());
-        assert_eq!((0.5 as Float).trunc(), 0.0);
-        assert!((0.5 as Float).trunc().is_sign_positive());
-        assert_eq!((-0.5 as Float).trunc(), -0.0);
-        assert!((-0.5 as Float).trunc().is_sign_negative());
-        assert_eq!(Float::MAX.trunc(), Float::MAX);
-        assert_eq!(Float::MIN.trunc(), Float::MIN);
-        assert_eq!(Float::MIN_POSITIVE.trunc(), 0.0);
-        assert_eq!((-Float::MIN_POSITIVE).trunc(), 0.0);
+        assert_biteq!((0.0 as Float).trunc(), 0.0);
+        assert_biteq!((-0.0 as Float).trunc(), -0.0);
+        assert_biteq!((0.5 as Float).trunc(), 0.0);
+        assert_biteq!((-0.5 as Float).trunc(), -0.0);
+        assert_biteq!(Float::MAX.trunc(), Float::MAX);
+        assert_biteq!(Float::MIN.trunc(), Float::MIN);
+        assert_biteq!(Float::MIN_POSITIVE.trunc(), 0.0);
+        assert_biteq!((-Float::MIN_POSITIVE).trunc(), -0.0);
         assert!(Float::NAN.trunc().is_nan());
-        assert_eq!(Float::INFINITY.trunc(), Float::INFINITY);
-        assert_eq!(Float::NEG_INFINITY.trunc(), Float::NEG_INFINITY);
+        assert_biteq!(Float::INFINITY.trunc(), Float::INFINITY);
+        assert_biteq!(Float::NEG_INFINITY.trunc(), Float::NEG_INFINITY);
     }
 }
 
@@ -604,19 +609,15 @@ float_test! {
         f128: #[cfg(any(miri, target_has_reliable_f128_math))],
     },
     test<Float> {
-        assert_eq!((0.0 as Float).fract(), 0.0);
-        assert!((0.0 as Float).fract().is_sign_positive());
-        assert_eq!((-0.0 as Float).fract(), 0.0);
-        assert!((-0.0 as Float).fract().is_sign_positive());
-        assert_eq!((0.5 as Float).fract(), 0.5);
-        assert!((0.5 as Float).fract().is_sign_positive());
-        assert_eq!((-0.5 as Float).fract(), -0.5);
-        assert!((-0.5 as Float).fract().is_sign_negative());
-        assert_eq!(Float::MAX.fract(), 0.0);
-        assert_eq!(Float::MIN.fract(), 0.0);
-        assert_eq!(Float::MIN_POSITIVE.fract(), Float::MIN_POSITIVE);
+        assert_biteq!((0.0 as Float).fract(), 0.0);
+        assert_biteq!((-0.0 as Float).fract(), 0.0);
+        assert_biteq!((0.5 as Float).fract(), 0.5);
+        assert_biteq!((-0.5 as Float).fract(), -0.5);
+        assert_biteq!(Float::MAX.fract(), 0.0);
+        assert_biteq!(Float::MIN.fract(), 0.0);
+        assert_biteq!(Float::MIN_POSITIVE.fract(), Float::MIN_POSITIVE);
         assert!(Float::MIN_POSITIVE.fract().is_sign_positive());
-        assert_eq!((-Float::MIN_POSITIVE).fract(), -Float::MIN_POSITIVE);
+        assert_biteq!((-Float::MIN_POSITIVE).fract(), -Float::MIN_POSITIVE);
         assert!((-Float::MIN_POSITIVE).fract().is_sign_negative());
         assert!(Float::NAN.fract().is_nan());
         assert!(Float::INFINITY.fract().is_nan());