Commit 1b884634 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(is_nonzero): New static function.

(check_one_stat): Don't report very small rounding errors when the
	correct value is 0.
parent 2f9f17ab
......@@ -36,6 +36,8 @@
#include <string.h>
#include <stdio.h>
#include <setjmp.h>
#include <float.h>
#include <math.h>
#include "stats.h"
#include "log.h"
......@@ -292,6 +294,16 @@ update_stat(enum stat_type st,
update_one_stat(st, VT_DESCEND, -delta, now);
}
static int
is_nonzero(double val)
{
#ifdef FP_ZERO
return fpclassify(val) != FP_ZERO;
#else
return val >= DBL_MIN || val <= -DBL_MIN;
#endif
}
static int
check_one_stat(enum stat_type st,
enum value_type vt,
......@@ -326,12 +338,18 @@ check_one_stat(enum stat_type st,
if ((acc < 1 && err > 1e5 * acc)
|| (acc >= 1 && err / acc > 1e-5))
{
kom_log("Accumulated rounding errors fixed (%s) after"
" %ld updates (st=%d, vt=%d, f=%d, factor=%d): %g => %g\n",
when,
s->updates[f], st, vt, f, factors[f], s->avenrun[f], acc);
/* Don't bother logging assignments to 0. */
if (is_nonzero(acc) || err > 1e-10)
{
kom_log("Accumulated rounding errors fixed (%s) after"
" %ld updates (st=%d, vt=%d, f=%d, factor=%d):"
" %g => %g\n",
when,
s->updates[f], st, vt, f, factors[f],
s->avenrun[f], acc);
s->updates[f] = 0;
}
s->avenrun[f] = acc;
s->updates[f] = 0;
changes++;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment