From 97ba9e4d4707cc14cd186ec73e50cac9687109c6 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 4 Jun 2014 10:48:03 +0200 Subject: [PATCH] local: round log value of clock precision This is similar to what the reference NTP implementation does. With 1us clock resolution that gives -20 instead of -19. --- local.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/local.c b/local.c index 513779e..158aa0c 100644 --- a/local.c +++ b/local.c @@ -126,11 +126,15 @@ calculate_sys_precision(void) assert(best_dusec > 0); precision_quantum = best_dusec * 1.0e-6; + + /* Get rounded log2 value of the measured precision */ precision_log = 0; - while (best_dusec < 500000) { + while (best_dusec < 707107) { precision_log--; best_dusec *= 2; } + + DEBUG_LOG(LOGF_Local, "Clock precision %.9f (%d)", precision_quantum, precision_log); } /* ================================================== */