From 9f2a41e6f3ec163944db3a0a89ef884895db704b Mon Sep 17 00:00:00 2001 From: Godzil Date: Fri, 14 Feb 2020 19:18:43 +0000 Subject: [PATCH] Change default precision to float instead of double (need to investigate there) Also add a way to dynamically change the precision (needed for some test that don't use non full precision result matrix) --- source/include/math_helper.h | 1 + source/math_helper.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/include/math_helper.h b/source/include/math_helper.h index 900e08e..65098b3 100644 --- a/source/include/math_helper.h +++ b/source/include/math_helper.h @@ -10,6 +10,7 @@ #ifndef DORAYME_MATH_HELPER_H #define DORAYME_MATH_HELPER_H +void set_equal_precision(double v); bool double_equal(double a, double b); #endif //DORAYME_MATH_HELPER_H diff --git a/source/math_helper.cpp b/source/math_helper.cpp index b86f2f9..4ce2a0b 100644 --- a/source/math_helper.cpp +++ b/source/math_helper.cpp @@ -11,7 +11,14 @@ #include #include +static double current_precision = FLT_EPSILON; + +void set_equal_precision(double v) +{ + current_precision = v; +} + bool double_equal(double a, double b) { - return fabs(a - b) < DBL_EPSILON; + return fabs(a - b) < current_precision; }