cgv
Loading...
Searching...
No Matches
compare_float.h
1#pragma once
2
3#include <limits>
4#include <type_traits>
5
6#define IS_FLOATING_POINT_GUARD typename std::enable_if<std::is_floating_point<T>::value, bool>::type = true
7
9namespace cgv {
10namespace math {
11
18template<typename T, IS_FLOATING_POINT_GUARD>
19bool is_equal(T a, T b) {
20 return std::abs(a - b) < std::numeric_limits<T>::epsilon();
21}
22
28template<typename T, IS_FLOATING_POINT_GUARD>
29bool is_zero(T x) {
30 return std::abs(x) < std::numeric_limits<T>::epsilon();
31}
32
33} // namespace math
34} // namespace cgv
35
36#undef IS_FLOATING_POINT_GUARD
the cgv namespace
Definition print.h:11