2 Checks for (in-)equality comparisons on floating-point
3 value and constant, except in functions called `*eq*` (which probably
4 implement equality for a type involving floats).
7 Floating point calculations are usually imprecise, so
8 asking if two values are *exactly* equal is asking for trouble. For a good
9 guide on what to do, see [the floating point
10 guide](http://www.floating-point-gui.de/errors/comparison).
15 const ONE: f64 = 1.00;
17 if x == ONE { } // where both are floats
22 let error_margin = f64::EPSILON; // Use an epsilon for comparison
23 // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead.
24 // let error_margin = std::f64::EPSILON;
25 if (x - ONE).abs() < error_margin { }