本文整理汇总了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