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

View file

@ -165,6 +165,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
string-format.h
string-format.cpp
strtod.c
subsurface-float.h
subsurface-string.h
subsurfacestartup.c
subsurfacestartup.h

View file

@ -15,6 +15,7 @@
#include "gettext.h"
#include "divesite.h"
#include "sample.h"
#include "subsurface-float.h"
#include "subsurface-string.h"
#include "device.h"
#include "dive.h"

View file

@ -24,8 +24,9 @@
#include "dive.h"
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "parse.h"
#include "subsurface-float.h"
#include "subsurface-string.h"
#include "subsurface-time.h"
#include "trip.h"
#include "device.h"

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "core/subsurface-string.h"
#include "qPrefDisplay.h"
#include "qPrefPrivate.h"
#include "core/subsurface-float.h"
#include <QApplication>
#include <QFont>

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "qPrefPrivate.h"
#include "core/subsurface-string.h"
#include "core/subsurface-float.h"
#include <QSettings>

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

View file

@ -5,7 +5,6 @@
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <math.h>
// shared generic definitions and macros
// mostly about strings, but a couple of math macros are here as well
@ -27,16 +26,6 @@
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;
}
// string handling
static inline bool same_string(const char *a, const char *b)