2 Checks for (in-)equality comparisons on floating-point
3 values (apart from zero), 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).
18 if y != x {} // where both are floats
23 let error_margin = f64::EPSILON; // Use an epsilon for comparison
24 // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead.
25 // let error_margin = std::f64::EPSILON;
26 if (y - 1.23f64).abs() < error_margin { }
27 if (y - x).abs() > error_margin { }