piCompare
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "pip_export.h"
|
||||
#include "pip_defs.h"
|
||||
#include "string.h"
|
||||
#include <limits>
|
||||
|
||||
//! Meta-information section for any entity.
|
||||
//! Parsing by \a pip_cmg and can be accessed by \a PICodeInfo.
|
||||
@@ -355,6 +356,17 @@ inline bool piCompareBinary(const void * f, const void * s, size_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! @brief Function for compare two numeric values with epsilon
|
||||
* \details Example:\n \snippet piincludes.cpp compare
|
||||
* There are some macros:
|
||||
* - \c piComparef for "float"
|
||||
* - \c piCompared for "double"
|
||||
*/
|
||||
template<typename T>
|
||||
inline bool piCompare(const T & a, const T & b, const T & epsilon = std::numeric_limits<T>::epsilon()) {
|
||||
return std::abs(a - b) <= epsilon;
|
||||
}
|
||||
|
||||
/*! @brief Templated function return round of float falue
|
||||
* \details Round is the nearest integer value \n
|
||||
* There are some macros:
|
||||
@@ -558,6 +570,8 @@ template<> inline uint piHash(const ldouble & v) {return piHashData((const uchar
|
||||
|
||||
#define piRoundf piRound<float>
|
||||
#define piRoundd piRound<double>
|
||||
#define piComparef piCompare<float>
|
||||
#define piCompared piCompare<double>
|
||||
#define piFloorf piFloor<float>
|
||||
#define piFloord piFloor<double>
|
||||
#define piCeilf piCeil<float>
|
||||
|
||||
Reference in New Issue
Block a user