System.Double.Equals Method

true if

objis an instance of double and equals the value of this instance; otherwise, false.

The double.Equals(double) method should be used with caution, because two apparently equivalent values can be unequal due to the differing precision of the two values. The following example reports that the double value .3333 and the double returned by dividing 1 by 3 are unequal.

code reference: System.Double.Epsilon#3

For alternatives to calling the double.Equals(object) method, see the documentation for the double.Equals(double) overload.

Because double.Epsilon defines the minimum expression of a positive value whose range is near zero, the margin of difference between two similar values must be greater than double.Epsilon. Typically, it is many times greater than double.Epsilon.

The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two particular numbers might change between versions of the .NET Framework because the precision of the numbers' internal representation might change.

If two double.NaN values are tested for equality by calling the double.Equals(double) method, the method returns true. However, if two double.NaN values are tested for equality by using the equality operator, the operator returns false. When you want to determine whether the value of a double is not a number (NaN), an alternative is to call the double.IsNaN(double) method.