From 25856ee829019d2c8bd4a684272b91d8b7a510cc Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 7 Dec 2019 22:43:35 +0100 Subject: Fix statistics output of negative temperatures. --- src/common/Core/stats.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/Core/stats.c b/src/common/Core/stats.c index 63aa6fa..e3239e3 100644 --- a/src/common/Core/stats.c +++ b/src/common/Core/stats.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "Core/stats.h" #include "Core/common.h" #include "vc.h" @@ -267,11 +268,16 @@ const char* stats_build_text(void) num_wind_generator_movements); if (temp_min != TEMP_INVALID && temp_max != TEMP_INVALID) { - const int temp_min_decidegree = 10.0f * temp_min; - const int temp_max_decidegree = 10.0f * temp_max; + const int temp_min_positive = (temp_min > 0); + const int temp_max_positive = (temp_max > 0); + + const int temp_min_decidegree = 10.0f * fabsf(temp_min); + const int temp_max_decidegree = 10.0f * fabsf(temp_max); stats_end_ix += snprintf(stats_text + stats_end_ix, STATS_LEN - 1 - stats_end_ix, - "Temp min,max= %dC%01d,%dC%01d\n", + "Temp min,max= %s%dC%01d,%s%dC%01d\n", + temp_min_positive ? "" : "-", temp_min_decidegree / 10, temp_min_decidegree % 10, + temp_max_positive ? "" : "-", temp_max_decidegree / 10, temp_max_decidegree % 10); } -- cgit v1.2.3