MathLib
Loading...
Searching...
No Matches
Functions
Comparison

Functions

int three_way_compare (float left, float right, float tolerance=0.0002f)
 
int three_way_compare (double left, double right, double tolerance=0.0002)
 
int three_way_compare (long double left, long double right, long double tolerance=0.0002l)
 

Detailed Description

Compare two values for equality, less-than, or greater-than with a tolerance

Parameters
leftThe left value to compare
rightThe right value to compare
toleranceThe minimum value for being considered equal
Returns
0 if the two are equal within tolerance , -1 if left < right , 1 if left > right
Note
This is similar to the three-way comparison operator (<=>), but with a tolerance for equality

Function Documentation

◆ three_way_compare() [1/3]

int three_way_compare ( double  left,
double  right,
double  tolerance = 0.0002 
)
inline

◆ three_way_compare() [2/3]

int three_way_compare ( float  left,
float  right,
float  tolerance = 0.0002f 
)
inline

◆ three_way_compare() [3/3]

int three_way_compare ( long double  left,
long double  right,
long double  tolerance = 0.0002l 
)
inline