diff --git a/src/stratifier.c b/src/stratifier.c index 70de9289..e87a2e31 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1276,7 +1276,12 @@ static void stratum_send_message(stratum_instance_t *client, const char *msg) static double time_bias(double tdiff, double period) { - return 1.0 - 1.0 / exp(tdiff / period); + double dexp = tdiff / period; + + /* Sanity check to prevent silly numbers for double accuracy **/ + if (unlikely(dexp > 36)) + dexp = 36; + return 1.0 - 1.0 / exp(dexp); } /* Sanity check to prevent clock adjustments backwards from screwing up stats */