Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
FloatToleranceEqual Struct Reference

Helper for float comparison with tolerance. More...

Public Member Functions

 FloatToleranceEqual (float tol=0.001f)
 Constructs a FloatToleranceEqual comparator with a specified tolerance.
 
bool operator() (float a, float b) const
 Compares two floating-point values for equality within the configured tolerance.
 

Public Attributes

float tolerance
 

Detailed Description

Helper for float comparison with tolerance.

Definition at line 1535 of file ah-functional.cc.

Constructor & Destructor Documentation

◆ FloatToleranceEqual()

FloatToleranceEqual::FloatToleranceEqual ( float  tol = 0.001f)
inline

Constructs a FloatToleranceEqual comparator with a specified tolerance.

The comparator considers two floating-point values equal when their absolute difference is less than or equal to the configured tolerance.

Parameters
tolTolerance threshold used for comparisons; defaults to 0.001.

Definition at line 1545 of file ah-functional.cc.

Member Function Documentation

◆ operator()()

bool FloatToleranceEqual::operator() ( float  a,
float  b 
) const
inline

Compares two floating-point values for equality within the configured tolerance.

Parameters
aFirst value to compare.
bSecond value to compare.
Returns
true if the absolute difference between a and b is less than or equal to tolerance, false otherwise.

Definition at line 1553 of file ah-functional.cc.

References tolerance.

Member Data Documentation

◆ tolerance

float FloatToleranceEqual::tolerance

Definition at line 1536 of file ah-functional.cc.

Referenced by operator()().


The documentation for this struct was generated from the following file: