27static constexpr double DEFAULT_MAX_DIFFERENCE = 1e-7;
48 std::enable_if_t<std::is_floating_point<T>::value,
bool> =
true>
52 T epsAbs =
static_cast<T
>(DEFAULT_MAX_DIFFERENCE),
53 T epsRel = std::numeric_limits<T>::epsilon()) ->
bool
56 T d = std::fabs(lhs - rhs);
63 T largest = std::max(r, l);
64 return d <= largest * epsRel;
Volume Cartographer library
auto AlmostEqual(const T lhs, const T rhs, T epsAbs=static_cast< T >(DEFAULT_MAX_DIFFERENCE), T epsRel=std::numeric_limits< T >::epsilon()) -> bool
Compare if two floating-point numbers are "almost equal".