We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2988c0a commit 290fe91Copy full SHA for 290fe91
library/core/tests/num/mod.rs
@@ -870,6 +870,17 @@ macro_rules! test_float {
870
assert!(($nan as $fty).midpoint(1.0).is_nan());
871
assert!((1.0 as $fty).midpoint($nan).is_nan());
872
assert!(($nan as $fty).midpoint($nan).is_nan());
873
+
874
+ // test if large differences in magnitude are still correctly computed.
875
+ // NOTE: that because of how small x and y are, x + y can never overflow
876
+ // so (x + y) / 2.0 is always correct
877
+ for i in 64..128 {
878
+ for j in 0..64u8 {
879
+ let x = (2.0f32.powi(i) + f32::from(j)) / 2.0;
880
+ let y = 2.0f32.powi(i).midpoint(f32::from(j));
881
+ assert_eq!(x, y);
882
+ }
883
884
}
885
#[test]
886
fn rem_euclid() {
0 commit comments