Function Math Complex Class

ApproxComplex

"Approximate" Return True if two expressions are approximately equal. Compare the real and imaginary parts of complex numbers separately.

Signature (Visual Basic / VBA)

Public Function ApproxComplex( _
      ByVal vX As Variant _
    , ByVal vY As Variant _
    , Optional ByVal vEpsilon As Variant _
    ) As Variant

Code Examples

    ApproxComplex(34.6, 34.59999999) = False
    ApproxComplex(34.6, 34.599999999999) = True
    ApproxComplex("SA", "sa") = False
    ApproxComplex("SA", "SA") = True
    If Y == 0: Abs(X) < Epsilon
    If Y <> 0: Abs(Y - X) / Y) < Epsilon

Parameters

Parameter Description
vX First of two numbers that are compared to see if they are approximately equal. Function returns Null if vX is Null or cannot be fixed up to a real or complex number (as defined by the ComplexStringToReals function).
vY Second of two numbers that are compared to see if they are approximately equal. Function returns Null if vY is Null or cannot be fixed up to a real or complex number.
vEpsilon Defines the range of "approximate" values as defined below. vEpsilon defaults to 1E-13 (10 ^ -13) if it is Null of cannot be fixed up to a (real) number.

Notes & Version History

Note If either of the arguments are not numbers, this function compares the values using the EqualLikeDataType function; it passes the arguments to that function and returns its result. In this case, it uses EqualLikeDataType with the Compare Mode of vbBinaryCompare.
v1.5 BugFix Fixed this function to use the vEpsilon argument instead of always using mcDOUBLE_EPSILON, which was 1E-13.
v1.5 Change This function has been renamed from Approx to ApproxComplex. There is a new Approx function whick works works on real numbers but not complex numbers.