I just read a statement about the floating point value comparison
Floating point values shall not be compared using either the == or !=
operators.
Most floating point values have no exact binary representation and have a
limited precision.
If so what is the best method for comparing two floating point values?
The following extension methods may be useful to implement Kevin’s suggestion:
So now you can just do:
Just change the
IsEqualToto a more appropriate name, or change the default margin to anything better thandouble.Epsilon, if needed.