From: Laurent Mazet Date: Sun, 28 Sep 2025 11:29:53 +0000 (+0200) Subject: fix histogram X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=99c7d0f93975c0269ae646a2343246cd3b5d2793;p=benchmarks.git fix histogram --- diff --git a/stat.c b/stat.c index 4e5850a..f28730e 100644 --- a/stat.c +++ b/stat.c @@ -84,7 +84,10 @@ void compute_statistics (int64_t *points, int nb, int bins) double gap = (max - min) / bins; for (int i = 0; i < nb - 1; i++) { - hist[(int)((points[i] - min) * bins / (max -min))]++; + int j = (points[i] - min) * bins / (max -min); + if (j < 0) j = 0; + if (j >= bins) j = bins - 1; + hist[j]++; } hist[bins - 1]++;