Complex::Equals Method (Complex)
Returns a value that indicates whether the current instance and a specified complex number have the same value.
Assembly: System.Numerics (in System.Numerics.dll)
The method provides the IEquatable<T> implementation for the Complex structure. It performs slightly better than Equals(Object) method because it does not have to convert its parameter to a complex number.
Two complex numbers are equal if their real parts are equal and their imaginary parts are equal. The method is equivalent to the following expression:Notes to Callers
Use the Equals method with caution, because two values that are apparently equivalent can be considered unequal due to the differing precision of their real and imaginary components. The following example reports that (3.33333, 0.142857) and (10/3, 1/7) are not equal.
One recommended technique is to define an acceptable margin of difference between the two values (such as .01% of one of the values' real and imaginary components) instead of comparing the values for equality. If the absolute value of the difference between the two values is less than or equal to that margin, the difference is likely to be due to a difference in precision, and, therefore, the values are likely to be equal. The following example uses this technique to compare the two complex values that the previous code example found to be unequal. It finds the two complex numbers to be equal.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.