From 99c7d0f93975c0269ae646a2343246cd3b5d2793 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Sun, 28 Sep 2025 13:29:53 +0200 Subject: [PATCH] fix histogram --- stat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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]++; -- 2.30.2