From 5833be6ccfb1bb97f18181dcad2d64640fd8561b Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 17 Mar 2016 14:28:45 +0100 Subject: [PATCH] util: fix UTI_FloatNetworkToHost() with very small exponents Fix conversion of floating point numbers from the cmdmon format with very small exponents, as for instance could be in the smoothing report when the smoothing process ends. This was broken in commit 8e71a46173afe01e11620980a1c7c028d7fd048f. --- util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index b654e63..9085ff6 100644 --- a/util.c +++ b/util.c @@ -807,9 +807,10 @@ UTI_FloatNetworkToHost(Float f) x = ntohl(f.f); - exp = (x >> FLOAT_COEF_BITS) - FLOAT_COEF_BITS; + exp = x >> FLOAT_COEF_BITS; if (exp >= 1 << (FLOAT_EXP_BITS - 1)) exp -= 1 << FLOAT_EXP_BITS; + exp -= FLOAT_COEF_BITS; coef = x % (1U << FLOAT_COEF_BITS); if (coef >= 1 << (FLOAT_COEF_BITS - 1))