From 3290d1223c022c9fc4d53252fb54d3a7e18df393 Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Sat, 19 Oct 2024 20:04:28 +0200 Subject: [PATCH] round with mathematics --- src/utils/helper.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/helper.cpp b/src/utils/helper.cpp index f974901e..f57bf368 100644 --- a/src/utils/helper.cpp +++ b/src/utils/helper.cpp @@ -6,6 +6,7 @@ #include "helper.h" #include "dbg.h" #include "../plugins/plugin_lang.h" +#include #define dt_SHORT_STR_LEN_i18n 3 // the length of short strings static char buffer_i18n[dt_SHORT_STR_LEN_i18n + 1]; // must be big enough for longest string and the terminating null @@ -37,11 +38,15 @@ namespace ah { } double round1(double value) { - return (int)(value * 10 + 0.5) / 10.0; + return round(value * 10) / 10.0; + } + + double round2(double value) { + return round(value * 100) / 100.0; } double round3(double value) { - return (int)(value * 1000 + 0.5) / 1000.0; + return round(value * 1000) / 1000.0; } String getDateTimeStr(time_t t) {