File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,9 @@ declare_clippy_lint! {
99
99
/// if y != x {} // where both are floats
100
100
///
101
101
/// // 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;
103
105
/// if (y - 1.23f64).abs() < error { }
104
106
/// if (y - x).abs() > error { }
105
107
/// ```
@@ -237,10 +239,12 @@ declare_clippy_lint! {
237
239
/// const ONE: f64 = 1.00;
238
240
///
239
241
/// // Bad
240
- /// if x == ONE { } // where both are floats
242
+ /// if x == ONE { } // where both are floats
241
243
///
242
244
/// // 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;
244
248
/// if (x - ONE).abs() < error { }
245
249
/// ```
246
250
pub FLOAT_CMP_CONST ,
You can’t perform that action at this time.
0 commit comments