Compares two numbers and returns True is they are within tolerance of each other.
equalTol? ( num1 As Number, _ num2 As Number, _ Optional tolerance As Number = 0.001 ) As Boolean
Argument | Type | Description |
---|---|---|
num1 | number | The first number to compare. |
num2 | number | The second number to compare. |
tolerance | Number | Optional; tolerance to use for the comparison; default is 0.001. If the numbers are different by no more than this value, then the numbers are considered equal. |
Intent >equalTol?(1.9996, 2.0004) --> TrueThis uses the default tolerance of 0.001.
Intent >equalTol?(1.96, 2.04) --> FalseThis uses the default tolerance of 0.001. Since the numbers are actually 0.08 apart, the comparison fails.
Intent >equalTol?(1.96, 2.04, tolerance := 0.1) --> TrueHere, a specific less-precise tolerance is specified, resulting in a match.