Approximate
This class provides a wrapper for numerical values to facilitate approximate equality comparisons. It allows users to compare a stored value against other numbers within a specified precision of decimal places. This is particularly useful for handling floating-point arithmetic discrepancies in unit tests or mathematical computations.
Attributes
| Attribute | Type | Description |
|---|---|---|
| val | number | The numeric value used as the baseline for approximate equality comparisons. |
| places | integer = 7 | The number of decimal places to which the difference between two values is rounded to determine equality. |
Constructor
Signature
def Approximate(
val: any,
places: int = 7
)
Parameters
| Name | Type | Description |
|---|---|---|
| val | any | The numeric value to be stored. |
| places | int = 7 | The number of decimal places to use when performing rounded equality comparisons. |