diff --git a/maths.hpp b/maths.hpp index 0fb66b52..48a5edd7 100644 --- a/maths.hpp +++ b/maths.hpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2010-2014 Danny Robson + * Copyright 2010-2018 Danny Robson */ #ifndef __MATHS_HPP @@ -81,6 +81,13 @@ namespace util { /////////////////////////////////////////////////////////////////////////// // Comparisons inline bool + relatively_equal (float a, float b, float percentage) + { + return std::abs (1 - b / a ) < percentage; + } + + //------------------------------------------------------------------------- + inline bool almost_equal (float a, float b) { return ieee_single::almost_equal (a, b);