X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftally%2Ftally.c;h=28a66a9f7fa0ebf384c62d69de8b04b396f71cad;hp=4c5e37e9e05d9eb256569573863e8e18714430be;hb=252bd427f813c2709c07e64378d5a6c67f51a922;hpb=e74c8a2bdf3e8ef45294d2b656150c07c4ca6294 diff --git a/ccan/tally/tally.c b/ccan/tally/tally.c index 4c5e37e9..28a66a9f 100644 --- a/ccan/tally/tally.c +++ b/ccan/tally/tally.c @@ -138,15 +138,17 @@ void tally_add(struct tally *tally, ssize_t val) new_max = val; need_renormalize = true; } - if (need_renormalize) + if (need_renormalize) { renormalize(tally, new_min, new_max); + } /* 128-bit arithmetic! If we didn't want exact mean, we could just * pull it out of counts. */ - if (val > 0 && tally->total[0] + val < tally->total[0]) + if (val > 0 && tally->total[0] + val < tally->total[0]) { tally->total[1]++; - else if (val < 0 && tally->total[0] + val > tally->total[0]) + } else if (val < 0 && tally->total[0] + val > tally->total[0]) { tally->total[1]--; + } tally->total[0] += val; tally->counts[bucket_of(tally->min, tally->step_bits, val)]++; }