本文整理匯總了VB.NET中System.Numerics.Complex.Equals方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Complex.Equals方法的具體用法?VB.NET Complex.Equals怎麽用?VB.NET Complex.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Numerics.Complex
的用法示例。
在下文中一共展示了Complex.Equals方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1:
Dim c1 As New System.Numerics.Complex(3.33333, .142857)
Dim c2 As New System.Numerics.Complex(10/3, 1/7)
Console.WriteLine("{0} = {1}: {2}", c1, c2, c1.Equals(c2))
輸出:
(3.33333, 0.142857) = (3.33333333333333, 0.142857142857143): False
示例2:
Dim c1 As New System.Numerics.Complex(3.33333, .142857)
Dim c2 As New System.Numerics.Complex(10/3.0, 1.0/7)
Dim difference As Double = .0001
' Compare the values
Dim result As Boolean = (Math.Abs(c1.Real - c2.Real) <= c1.Real * difference) And
(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:
Dim n1 As Double = 16.33
Dim c1 As New System.Numerics.Complex(16.33, 0)
Console.WriteLine(c1.Equals(n1)) ' Returns True.
示例4: Example
' 導入命名空間
Imports System.Numerics
Module Example
Public Sub Main()
Dim n1 As Single = 1.430718e-12
Dim c1 As New Complex(1.430718e-12, 0)
Console.WriteLine("{0} = {1}: {2}", c1, n1, c1.Equals(n1))
End Sub
End Module
輸出:
(1.430718E-12, 0) = 1.430718E-12: False
示例5: Main
' 導入命名空間
Imports System.Numerics
Module Example
Public Sub Main()
Dim n1 As Single = 1.430718e-12
Dim c1 As New Complex(1.430718e-12, 0)
Dim difference As Double = .0001
' Compare the values
Dim result As Boolean = (Math.Abs(c1.Real - n1) <= c1.Real * difference) And
c1.Imaginary = 0
Console.WriteLine("{0} = {1}: {2}", c1, n1, result)
End Sub
End Module
輸出:
(1.430718E-12, 0) = 1.430718E-12: True