osrm-backend/include/util/floating_point.hpp

23 lines
452 B
C++
Raw Normal View History

2015-01-27 11:44:46 -05:00
#ifndef FLOATING_POINT_HPP
#define FLOATING_POINT_HPP
#include <cmath>
#include <limits>
#include <type_traits>
namespace osrm
{
2016-01-05 10:51:13 -05:00
namespace util
{
2015-01-27 11:44:46 -05:00
template <typename FloatT> bool epsilon_compare(const FloatT number1, const FloatT number2)
{
static_assert(std::is_floating_point<FloatT>::value, "type must be floating point");
return (std::abs(number1 - number2) < std::numeric_limits<FloatT>::epsilon());
}
2016-01-05 10:51:13 -05:00
}
2015-01-27 11:44:46 -05:00
}
#endif // FLOATING_POINT_HPP