Add maths check for integer numbers on doubles
This commit is contained in:
parent
64dd72db85
commit
fc0b978ac1
12
maths.cpp
12
maths.cpp
@ -57,6 +57,18 @@ template double rootsquare (double, double);
|
|||||||
template double rootsquare ( int, int);
|
template double rootsquare ( int, int);
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
is_integer (const T &value) {
|
||||||
|
T integer;
|
||||||
|
return exactly_equal (std::modf (value, &integer),
|
||||||
|
static_cast<T> (0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template bool is_integer (const double&);
|
||||||
|
template bool is_integer (const float&);
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
bool
|
bool
|
||||||
almost_equal (const float &a, const float &b)
|
almost_equal (const float &a, const float &b)
|
||||||
|
@ -49,6 +49,12 @@ T
|
|||||||
round_pow2 (T value) pure;
|
round_pow2 (T value) pure;
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
is_integer (const T& value) pure;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if two floating point numbers are approximately equal. Returns true
|
* Check if two floating point numbers are approximately equal. Returns true
|
||||||
* if the difference is less than a percentage of each individual value.
|
* if the difference is less than a percentage of each individual value.
|
||||||
|
Loading…
Reference in New Issue
Block a user