diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-07 22:43:35 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-07 22:43:35 +0100 |
commit | 25856ee829019d2c8bd4a684272b91d8b7a510cc (patch) | |
tree | 37ff3afe7bdd900cb5c8e97f789d0c00ae8d53b9 | |
parent | 8092333e3bc4fa75019093045dca9fb0ea8479b5 (diff) | |
download | glutte-o-matic-25856ee829019d2c8bd4a684272b91d8b7a510cc.tar.gz glutte-o-matic-25856ee829019d2c8bd4a684272b91d8b7a510cc.tar.bz2 glutte-o-matic-25856ee829019d2c8bd4a684272b91d8b7a510cc.zip |
Fix statistics output of negative temperatures.
-rw-r--r-- | src/common/Core/stats.c | 12 |
1 files 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 <string.h> #include <stdio.h> #include <stdint.h> +#include <math.h> #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); } |