Equals
From Xojo Documentation
Method
Tests whether two Single or Double numbers are equal to a specified tolerance.
Syntax
result=expression.Equals(numValue, maxUIps)
Part | Type | Description |
---|---|---|
expression | Single or Double | The numeric expression that your are testing against NumValue. |
maxUlps | Int32 | The number of units in the last position that are used to denote the acceptable range in the test of equality. The default is 1. If you pass zero, then the test is the same as with =. |
numValue | Single or Double | The numeric expression that Expression is being compared to. |
Result | Boolean | True if Expression and NumValue are equal within the tolerance specified by MaxUlps. |
Notes
Use Equals rather than = when you need to determine whether two floating point numbers are close enough in value to be considered “equal.” This can be used to account for the imprecision of floating point division on computers, for example. It allows for a user-specified rounding error.
The MaxUlps parameter allows you to specify the allowable range of values. For example:
The values of x which will satisfy the equality test are: 10000.000000000002, 10000.0 and 9999.999999999998.
Examples
Dim PI as Double = 3.14159265358979323846264338327950
If PI.Equals(22/7,1)
MsgBox "The comparison is True"
End if
If PI.Equals(22/7,1)
MsgBox "The comparison is True"
End if