Template Function librapid::isClose(const V&, const V&, const T&)#

Function Documentation#

template<typename V, typename T>
bool librapid::isClose(const V &val1, const V &val2, const T &tolerance = 1e-6)#

Returns true if the two values are within the given tolerance of each other.

This function is often used to compare floating point values for equality, since floating point rounding errors can cause exact equality checks to fail.

Template Parameters
  • V – Data type of the values to compare

  • T – Data type of the tolerance value

Parameters
  • val1 – First value

  • val2 – Second value

  • tolerance – Tolerance

Returns

True if values are close