Skip to main content

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

AttributeTypeDescription
valnumberThe numeric value used as the baseline for approximate equality comparisons.
placesinteger = 7The 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

NameTypeDescription
valanyThe numeric value to be stored.
placesint = 7The number of decimal places to use when performing rounded equality comparisons.