本文整理匯總了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