namespace
typesClasses
-
template<typename T>class CompareApproximatelyEqual
- Helper class that memorizes the comparison setttings.
Functions
-
template<typename T>auto is_approximately_equal(T a, T b, T epsilon = std::
numeric_limits<T>::epsilon(), int maxUlpsDiff = 10) -> bool -
template<typename T>auto is_equal(const T& a, const T& b) -> bool
- Compare values equality.
-
template<typename T>auto is_greater_or_equal(const T& a, const T& b) -> bool
- Compare values inequality: "is greater or equal to".
-
template<typename T>auto is_approximately_greater_or_equal(const T& a, const T& b, T epsilon = std::
numeric_limits<T>::epsilon(), int maxUlpsDiff = 10) -> bool - Compare values inequality: "is greater or approximately equal to".
-
template<typename T>auto is_approximately_lesser_or_equal(const T& a, const T& b, T epsilon = std::
numeric_limits<T>::epsilon(), int maxUlpsDiff = 10) -> bool - Compare values inequality: "is less or approximately equal to".
-
template<typename T>auto is_strictly_greater(const T& a, const T& b, T epsilon = std::
numeric_limits<T>::epsilon(), int maxUlpsDiff = 10) -> bool - Compare values inequality: "is strictly greater than".
- auto is_approximately_equal(float a, float b, float epsilon, int maxUlpsDiff) -> template bool
- auto is_approximately_equal(double a, double b, double epsilon, int maxUlpsDiff) -> template bool
Function documentation
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_approximately_equal(T a,
T b,
T epsilon = std:: numeric_limits<T>::epsilon(),
int maxUlpsDiff = 10)
Compare 2 floats with an absolute epsilon check (values near zero), then based on ULPs
epsilon : epsilon for floating-point absolute epsilon check (should be some small multiple of std::
Assumptions:
- Bit identical numbers are equal for any epsilon.
- A NaN is different from any number (even another NaN).
- Infinity is different from any number but infinity (with the same sign).
- Subnormal numbers are treated as equal to 0
- +/-std::numeric_limits<T>::min() has ULP distance 1 from 0
- -std::
numeric_limits<T>:: min() has ULP distance 2 from std:: numeric_limits<T>:: min() - ULP distance from 0 is 1 + ULP distance from std::
numeric_limits<T>:: min() (for positive numbers) Compares values equality within a range defined by an epsilon and a This function only has specializations for double and float
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_equal(const T& a,
const T& b)
Compare values equality.
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_greater_or_equal(const T& a,
const T& b)
Compare values inequality: "is greater or equal to".
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_approximately_greater_or_equal(const T& a,
const T& b,
T epsilon = std:: numeric_limits<T>::epsilon(),
int maxUlpsDiff = 10)
Compare values inequality: "is greater or approximately equal to".
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_approximately_lesser_or_equal(const T& a,
const T& b,
T epsilon = std:: numeric_limits<T>::epsilon(),
int maxUlpsDiff = 10)
Compare values inequality: "is less or approximately equal to".
#include <eckit/types/FloatCompare.h>
template<typename T>
bool eckit:: types:: is_strictly_greater(const T& a,
const T& b,
T epsilon = std:: numeric_limits<T>::epsilon(),
int maxUlpsDiff = 10)
Compare values inequality: "is strictly greater than".
template bool eckit:: types:: is_approximately_equal(float a,
float b,
float epsilon,
int maxUlpsDiff)
#include <eckit/types/FloatCompare.h>
template bool eckit:: types:: is_approximately_equal(double a,
double b,
double epsilon,
int maxUlpsDiff)
#include <eckit/types/FloatCompare.h>