From e02ae075ce9626f64cbc4e61024fa4610c21bcd3 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 23 Feb 2017 12:56:30 +0100 Subject: [PATCH] chrony: fix conversion of very small floating-poing values This is copied from the chrony code. --- src/chrony.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- 2.11.0