本文整理汇总了C#中System.Complex.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Equals方法的具体用法?C# Complex.Equals怎么用?C# Complex.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Complex
的用法示例。
在下文中一共展示了Complex.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals
public void Equals()
{
Complex<double> actual = new Complex<double>(1, 2);
Complex<double> expected = new Complex<double>(2, 3);
Assert.True(actual.Equals(actual));
Assert.AreEqual(actual.Equals(expected), expected.Equals(actual));
}
示例2: Divide
public void Divide()
{
Complex actual = number1.Divide(number2);
Complex expected = new Complex((number1.re * number2.re + number1.im * number2.im) / (number2.re * number2.re + number2.im * number2.im), (number1.im * number2.re - number1.re * number2.im) / (number2.re * number2.re + number2.im * number2.im));
Assert.True(expected.Equals(actual));
}
示例3: Main
static void Main(string[] args)
{
try
{
Numbers[] n = new Numbers[6] { new Complex(), new Complex(2, 1), new Complex(2, 3),new Fraction(), new Fraction(1), new Fraction(2,5) };
Console.WriteLine("a=" + n[1].ToString());
Console.WriteLine("b=" + n[2].ToString());
n[0] = (Complex)n[1] + (Complex)n[2];
Console.WriteLine("a+b=" + n[0].ToString());
n[0] = (Complex)n[1] / (Complex)n[2];
Console.WriteLine("a/b=" + n[0].ToString());
n[0] = (Complex)n[1] - (Complex)n[2];
Console.WriteLine("a-b=" + n[0].ToString());
n[0] = (Complex)n[1] * (Complex)n[2];
Console.WriteLine("a*b=" + n[0].ToString());
Console.WriteLine("test=" + n[1].ToString());
Console.WriteLine("спряжене= " + ((Complex)n[1]).conjugate());
double n1 = 2.0;
Console.WriteLine(((Complex)n[1]).Root(n1));
Console.WriteLine(((Complex)n[1]).Pow(n1));
Console.WriteLine("+++++++++++++++++++++++");
Fraction a1 = new Fraction(1);
Console.WriteLine("1+2/5=");
Fraction b1 = new Fraction(2, 5);
n[3] = (Fraction)n[4] + (Fraction)n[5];
Console.WriteLine(n[3].ToString());
Console.WriteLine("1-2/5=");
n[3] = (Fraction)n[4] - (Fraction)n[5];
Console.WriteLine(n[3].ToString());
Console.WriteLine("1*2/5=");
n[3] = (Fraction)n[4] * (Fraction)n[5];
Console.WriteLine(n[3].ToString());
Console.WriteLine("1 : 2/5=");
n[3] = (Fraction)n[4] / (Fraction)n[5];
Console.WriteLine(n[3].ToString());
Console.WriteLine();
Console.WriteLine("1<2/5");
Console.WriteLine((Fraction)n[4] < (Fraction)n[5]);
Console.WriteLine();
Console.WriteLine("1>2/5");
Console.WriteLine((Fraction)n[4] > (Fraction)n[5]);
Console.WriteLine();
Console.WriteLine("1<=2/5");
Console.WriteLine((Fraction)n[4] <= (Fraction)n[5]);
Console.WriteLine();
Console.WriteLine("1>=2/5");
Console.WriteLine((Fraction)n[4] >= (Fraction)n[5]);
Console.WriteLine();
Console.WriteLine("1==2/5");
Console.WriteLine((Fraction)n[4] == (Fraction)n[5]);
Console.WriteLine();
Console.WriteLine("1!=2/5");
Console.WriteLine((Fraction)n[4] != (Fraction)n[5]);
Fraction mm = new Fraction(2, 2);
Complex mn = new Complex(2, 2);
if (mn.Equals(mm))
Console.WriteLine("+++");
else
Console.WriteLine("---");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}