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)
This commit is contained in:
Godzil
2020-02-14 19:18:43 +00:00
parent 95c7616646
commit 9f2a41e6f3
2 changed files with 9 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
#ifndef DORAYME_MATH_HELPER_H #ifndef DORAYME_MATH_HELPER_H
#define DORAYME_MATH_HELPER_H #define DORAYME_MATH_HELPER_H
void set_equal_precision(double v);
bool double_equal(double a, double b); bool double_equal(double a, double b);
#endif //DORAYME_MATH_HELPER_H #endif //DORAYME_MATH_HELPER_H

View File

@@ -11,7 +11,14 @@
#include <float.h> #include <float.h>
#include <math_helper.h> #include <math_helper.h>
static double current_precision = FLT_EPSILON;
void set_equal_precision(double v)
{
current_precision = v;
}
bool double_equal(double a, double b) bool double_equal(double a, double b)
{ {
return fabs(a - b) < DBL_EPSILON; return fabs(a - b) < current_precision;
} }