C# Complex Equals(Complex)
Description
Complex Equals(Complex)
Returns a value that indicates
whether the current instance and a specified complex number have the same
value.
Syntax
Complex.Equals(Complex)
has the following syntax.
public bool Equals(
Complex value
)
Parameters
Complex.Equals(Complex)
has the following parameters.
value
- The complex number to compare.
Returns
Complex.Equals(Complex)
method returns true if this complex number and value have the same value; otherwise, false.
Example
/*from w w w .ja va 2 s. c om*/
using System;
using System.IO;
using System.Numerics;
public class Example
{
public static void Main()
{
System.Numerics.Complex c1 = new System.Numerics.Complex(3.33333, .142857);
System.Numerics.Complex c2 = new System.Numerics.Complex(10/3.0, 1.0/7);
Console.WriteLine("{0} = {1}: {2}", c1, c2, c1.Equals(c2));
c1 = new System.Numerics.Complex(3.33333, .142857);
c2 = new System.Numerics.Complex(10/3.0, 1.0/7);
double difference = .0001;
bool result = (Math.Abs(c1.Real - c2.Real) <= c1.Real * difference) &
(Math.Abs(c1.Imaginary - c2.Imaginary) <= c1.Imaginary * difference);
Console.WriteLine("{0} = {1}: {2}", c1, c2, result);
}
}
The code above generates the following result.