mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
61701509b0
commit
aa4b48f440
12 changed files with 35 additions and 20 deletions
|
@ -165,6 +165,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
||||||
string-format.h
|
string-format.h
|
||||||
string-format.cpp
|
string-format.cpp
|
||||||
strtod.c
|
strtod.c
|
||||||
|
subsurface-float.h
|
||||||
subsurface-string.h
|
subsurface-string.h
|
||||||
subsurfacestartup.c
|
subsurfacestartup.c
|
||||||
subsurfacestartup.h
|
subsurfacestartup.h
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "divesite.h"
|
#include "divesite.h"
|
||||||
#include "sample.h"
|
#include "sample.h"
|
||||||
|
#include "subsurface-float.h"
|
||||||
#include "subsurface-string.h"
|
#include "subsurface-string.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "divesite.h"
|
#include "divesite.h"
|
||||||
#include "errorhelper.h"
|
#include "errorhelper.h"
|
||||||
#include "subsurface-string.h"
|
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
#include "subsurface-float.h"
|
||||||
|
#include "subsurface-string.h"
|
||||||
#include "subsurface-time.h"
|
#include "subsurface-time.h"
|
||||||
#include "trip.h"
|
#include "trip.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "core/subsurface-string.h"
|
|
||||||
#include "qPrefDisplay.h"
|
#include "qPrefDisplay.h"
|
||||||
#include "qPrefPrivate.h"
|
#include "qPrefPrivate.h"
|
||||||
|
#include "core/subsurface-float.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "qPrefPrivate.h"
|
#include "qPrefPrivate.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-float.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
|
24
core/subsurface-float.h
Normal file
24
core/subsurface-float.h
Normal 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
|
|
@ -5,7 +5,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
// shared generic definitions and macros
|
// shared generic definitions and macros
|
||||||
// mostly about strings, but a couple of math macros are here as well
|
// mostly about strings, but a couple of math macros are here as well
|
||||||
|
@ -27,16 +26,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
// string handling
|
||||||
|
|
||||||
static inline bool same_string(const char *a, const char *b)
|
static inline bool same_string(const char *a, const char *b)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/divelist.h"
|
#include "core/divelist.h"
|
||||||
#include "core/settings/qPrefDiveComputer.h"
|
#include "core/settings/qPrefDiveComputer.h"
|
||||||
|
#include "core/subsurface-float.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-string.h"
|
||||||
#include "core/uemis.h"
|
#include "core/uemis.h"
|
||||||
#include "core/downloadfromdcthread.h"
|
#include "core/downloadfromdcthread.h"
|
||||||
|
@ -169,8 +170,6 @@ void DownloadFromDCWidget::DC##num##Clicked() \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DCBUTTON(1)
|
DCBUTTON(1)
|
||||||
DCBUTTON(2)
|
DCBUTTON(2)
|
||||||
DCBUTTON(3)
|
DCBUTTON(3)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "themeinterface.h"
|
#include "themeinterface.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-float.h"
|
||||||
#include "qmlmanager.h"
|
#include "qmlmanager.h"
|
||||||
#include "core/metrics.h"
|
#include "core/metrics.h"
|
||||||
#include "core/settings/qPrefDisplay.h"
|
#include "core/settings/qPrefDisplay.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "profile-widget/divetextitem.h"
|
#include "profile-widget/divetextitem.h"
|
||||||
#include "core/profile.h"
|
#include "core/profile.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-float.h"
|
||||||
#include "profile-widget/animationfunctions.h"
|
#include "profile-widget/animationfunctions.h"
|
||||||
#include "profile-widget/divelineitem.h"
|
#include "profile-widget/divelineitem.h"
|
||||||
#include "profile-widget/profilescene.h"
|
#include "profile-widget/profilescene.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "profilescene.h"
|
#include "profilescene.h"
|
||||||
#include "mobile-widgets/qmlmanager.h"
|
#include "mobile-widgets/qmlmanager.h"
|
||||||
#include "core/errorhelper.h"
|
#include "core/errorhelper.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-float.h"
|
||||||
#include "core/metrics.h"
|
#include "core/metrics.h"
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "testunitconversion.h"
|
#include "testunitconversion.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-float.h"
|
||||||
|
|
||||||
void TestUnitConversion::testUnitConversions()
|
void TestUnitConversion::testUnitConversions()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue