From 6a478eec5eb40f7b9885cc7f5c1f63afa599e00e Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 27 Oct 2022 18:37:08 +0200 Subject: [PATCH] fix #704 round div100 temperatures to one decimal --- src/helpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers.cpp b/src/helpers.cpp index 72b66a418..030eccda6 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -297,7 +297,7 @@ char * Helpers::render_value(char * result, const int32_t value, const int8_t fo } else if (format > 0) { strlcat(result, itoa(new_value / format, s, 10), sizeof(s)); strlcat(result, ".", sizeof(s)); - strlcat(result, itoa(new_value % format, s, 10), sizeof(s)); + strlcat(result, itoa((new_value % format + format / 2) * 10 / format, s, 10), sizeof(s)); } else { strlcat(result, itoa(new_value * format * -1, s, 10), sizeof(s)); } @@ -347,7 +347,7 @@ char * Helpers::render_value(char * result, const uint32_t value, const int8_t f } else if (format > 0) { strlcpy(result, ltoa(new_value / format, s, 10), sizeof(s)); strlcat(result, ".", sizeof(s)); - strlcat(result, ltoa(new_value % format, s, 10), sizeof(s)); + strlcat(result, itoa((new_value % format + format / 2) * 10 / format, s, 10), sizeof(s)); } else { strlcpy(result, ltoa(new_value * format * -1, s, 10), sizeof(s)); }