本文整理汇总了C#中System.Numerics.Complex.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Equals方法的具体用法?C# Complex.Equals怎么用?C# Complex.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Numerics.Complex
的用法示例。
在下文中一共展示了Complex.Equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
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));
输出:
(3.33333, 0.142857) = (3.33333333333333, 0.142857142857143): False
示例2:
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);
double difference = .0001;
// Compare the values
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);
输出:
(3.33333, 0.142857) = (3.33333333333333, 0.142857142857143): True
示例3:
double n1 = 16.33;
System.Numerics.Complex c1 =
new System.Numerics.Complex(16.33, 0);
Console.WriteLine(c1.Equals(n1)); // Returns true.
示例4: Main
//引入命名空间
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
float n1 = 1.430718e-12f;
Complex c1 = new Complex(1.430718e-12, 0);
Console.WriteLine("{0} = {1}: {2}", c1, n1, c1.Equals(n1));
}
}
输出:
(1.430718E-12, 0) = 1.430718E-12: False
示例5: Main
//引入命名空间
using System.Numerics;
public class Example
{
public static void Main()
{
float n1 = 1.430718e-12f;
Complex c1 = new Complex(1.430718e-12, 0);
double difference = .0001;
// Compare the values
bool result = (Math.Abs(c1.Real - n1) <= c1.Real * difference) &
c1.Imaginary == 0;
Console.WriteLine("{0} = {1}: {2}", c1, n1, result);
}
}
输出:
(1.430718E-12, 0) = 1.430718E-12: True