diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 2fe7a7707..54cafd7d6 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -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
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index 0d4781619..fbb1696fd 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -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"
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 2600d10b7..6212b9e4e 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -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"
diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp
index d49826d23..4e8b83d62 100644
--- a/core/settings/qPrefDisplay.cpp
+++ b/core/settings/qPrefDisplay.cpp
@@ -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>
diff --git a/core/settings/qPrefPrivate.cpp b/core/settings/qPrefPrivate.cpp
index 0d07bf17d..a5a67be0d 100644
--- a/core/settings/qPrefPrivate.cpp
+++ b/core/settings/qPrefPrivate.cpp
@@ -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>
 
diff --git a/core/subsurface-float.h b/core/subsurface-float.h
new file mode 100644
index 000000000..4dc225728
--- /dev/null
+++ b/core/subsurface-float.h
@@ -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
diff --git a/core/subsurface-string.h b/core/subsurface-string.h
index e02cdd337..e2127d02c 100644
--- a/core/subsurface-string.h
+++ b/core/subsurface-string.h
@@ -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)
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 7cdc368b6..bb61171a6 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -4,6 +4,7 @@
 #include "core/qthelper.h"
 #include "core/divelist.h"
 #include "core/settings/qPrefDiveComputer.h"
+#include "core/subsurface-float.h"
 #include "core/subsurface-string.h"
 #include "core/uemis.h"
 #include "core/downloadfromdcthread.h"
@@ -169,8 +170,6 @@ void DownloadFromDCWidget::DC##num##Clicked() \
 }
 #endif
 
-
-
 DCBUTTON(1)
 DCBUTTON(2)
 DCBUTTON(3)
diff --git a/mobile-widgets/themeinterface.cpp b/mobile-widgets/themeinterface.cpp
index af633cb6f..6d31108e3 100644
--- a/mobile-widgets/themeinterface.cpp
+++ b/mobile-widgets/themeinterface.cpp
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "themeinterface.h"
-#include "core/subsurface-string.h"
+#include "core/subsurface-float.h"
 #include "qmlmanager.h"
 #include "core/metrics.h"
 #include "core/settings/qPrefDisplay.h"
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp
index 33cf492e5..b4f46da85 100644
--- a/profile-widget/divecartesianaxis.cpp
+++ b/profile-widget/divecartesianaxis.cpp
@@ -3,7 +3,7 @@
 #include "profile-widget/divetextitem.h"
 #include "core/profile.h"
 #include "core/qthelper.h"
-#include "core/subsurface-string.h"
+#include "core/subsurface-float.h"
 #include "profile-widget/animationfunctions.h"
 #include "profile-widget/divelineitem.h"
 #include "profile-widget/profilescene.h"
diff --git a/profile-widget/qmlprofile.cpp b/profile-widget/qmlprofile.cpp
index 0ff3ce13e..121ba2911 100644
--- a/profile-widget/qmlprofile.cpp
+++ b/profile-widget/qmlprofile.cpp
@@ -3,7 +3,7 @@
 #include "profilescene.h"
 #include "mobile-widgets/qmlmanager.h"
 #include "core/errorhelper.h"
-#include "core/subsurface-string.h"
+#include "core/subsurface-float.h"
 #include "core/metrics.h"
 #include <QTransform>
 #include <QScreen>
diff --git a/tests/testunitconversion.cpp b/tests/testunitconversion.cpp
index a0cc547dc..2a4d10dd3 100644
--- a/tests/testunitconversion.cpp
+++ b/tests/testunitconversion.cpp
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "testunitconversion.h"
 #include "core/dive.h"
-#include "core/subsurface-string.h"
+#include "core/subsurface-float.h"
 
 void TestUnitConversion::testUnitConversions()
 {