From: Miroslav Lichvar Date: Thu, 23 Feb 2017 11:56:30 +0000 (+0100) Subject: chrony: fix conversion of very small floating-poing values X-Git-Tag: collectd-5.8.0~172^2~5 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e02ae075ce9626f64cbc4e61024fa4610c21bcd3;p=collectd.git chrony: fix conversion of very small floating-poing values This is copied from the chrony code. --- diff --git a/src/chrony.c b/src/chrony.c index 0733e130..6cf29144 100644 --- a/src/chrony.c +++ b/src/chrony.c @@ -584,9 +584,10 @@ static double ntohf(tFloat p_float) { uint32_t uval; uval = ntohl(p_float.value); - exp = (uval >> FLOAT_COEF_BITS) - FLOAT_COEF_BITS; + exp = (uval >> FLOAT_COEF_BITS); if (exp >= 1 << (FLOAT_EXP_BITS - 1)) exp -= 1 << FLOAT_EXP_BITS; + exp -= FLOAT_COEF_BITS; /* coef = (x << FLOAT_EXP_BITS) >> FLOAT_EXP_BITS; */ coef = uval % (1U << FLOAT_COEF_BITS);