1 #![warn(clippy::float_cmp)]
2 #![allow(unused, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)]
7 const ONE: f32 = ZERO + 1.0;
11 T: Add<T, Output = T> + Copy,
16 fn eq_fl(x: f32, y: f32) -> bool {
21 } // no error, inside "eq" fn
24 fn fl_eq(x: f32, y: f32) -> bool {
29 } // no error, inside "eq" fn
36 impl PartialEq for X {
37 fn eq(&self, o: &X) -> bool {
38 if self.val.is_nan() {
41 self.val == o.val // no error, inside "eq" fn
47 ZERO == 0f32; //no error, comparison with zero is ok
48 1.0f32 != f32::INFINITY; // also comparison with infinity
49 1.0f32 != f32::NEG_INFINITY; // and negative infinity
50 ZERO == 0.0; //no error, comparison with zero is ok
51 ZERO + ZERO != 1.0; //no error, comparison with zero is ok
55 ONE + ONE == ZERO + ONE + ONE;
57 ONE != 0.0; // no error, comparison with zero is ok
60 ONE as f64 != 0.0; // no error, comparison with zero is ok
65 x != 0f64; // no error, comparison with zero is ok
67 twice(x) != twice(ONE as f64);
69 x < 0.0; // no errors, lower or greater comparisons need no fuzzyness
74 let xs: [f32; 1] = [0.0];
75 let a: *const f32 = xs.as_ptr();
76 let b: *const f32 = xs.as_ptr();
78 assert_eq!(a, b); // no errors
80 // no errors - comparing signums is ok
82 1.23f32.signum() == x32.signum();
83 1.23f32.signum() == -(x32.signum());
84 1.23f32.signum() == 3.21f32.signum();
86 1.23f32.signum() != x32.signum();
87 1.23f32.signum() != -(x32.signum());
88 1.23f32.signum() != 3.21f32.signum();
91 1.23f64.signum() == x64.signum();
92 1.23f64.signum() == -(x64.signum());
93 1.23f64.signum() == 3.21f64.signum();
95 1.23f64.signum() != x64.signum();
96 1.23f64.signum() != -(x64.signum());
97 1.23f64.signum() != 3.21f64.signum();