core: move floating point functions to own header file

This were in subsurface-string.h for unknown reasons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-08-30 18:13:13 +02:00 committed by Robert C. Helling
parent 61701509b0
commit aa4b48f440
12 changed files with 35 additions and 20 deletions

24
core/subsurface-float.h Normal file
View file

@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef SUBSURFACE_FLOAT_H
#define SUBSURFACE_FLOAT_H
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline bool nearly_equal(double a, double b)
{
return fabs(a - b) <= 1e-6 * fmax(fabs(a), fabs(b));
}
static inline bool nearly_0(double fp)
{
return fabs(fp) <= 1e-6;
}
#ifdef __cplusplus
}
#endif
#endif // SUBSURFACE_FLOAT_H