File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,9 @@ declare_clippy_lint! {
9999 /// if y != x {} // where both are floats
100100 ///
101101 /// // Good
102- /// let error = 0.01f64; // Use an epsilon for comparison
102+ /// let error = f64::EPSILON; // Use an epsilon for comparison
103+ /// // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead.
104+ /// // let error = std::f64::EPSILON;
103105 /// if (y - 1.23f64).abs() < error { }
104106 /// if (y - x).abs() > error { }
105107 /// ```
@@ -237,10 +239,12 @@ declare_clippy_lint! {
237239 /// const ONE: f64 = 1.00;
238240 ///
239241 /// // Bad
240- /// if x == ONE { } // where both are floats
242+ /// if x == ONE { } // where both are floats
241243 ///
242244 /// // Good
243- /// let error = 0.1f64; // Use an epsilon for comparison
245+ /// let error = f64::EPSILON; // Use an epsilon for comparison
246+ /// // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead.
247+ /// // let error = std::f64::EPSILON;
244248 /// if (x - ONE).abs() < error { }
245249 /// ```
246250 pub FLOAT_CMP_CONST ,
You can’t perform that action at this time.
0 commit comments