Skip to content

Commit d979d5b

Browse files
authored
map 100 to last bin in histogram baseline (#44)
1 parent 9a9220b commit d979d5b

File tree

1 file changed

+2
-1
lines changed
  • drivers/cpp/benchmarks/histogram/21_histogram_bin_0-100

1 file changed

+2
-1
lines changed

drivers/cpp/benchmarks/histogram/21_histogram_bin_0-100/baseline.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
*/
1212
void NO_INLINE correctBinsBy10Count(std::vector<double> const& x, std::array<size_t, 10> &bins) {
1313
for (size_t i = 0; i < x.size(); i += 1) {
14-
const size_t bin = x[i] / 10;
14+
size_t bin = static_cast<size_t>(x[i] / 10);
15+
bin = std::min(bin, bins.size() - 1);
1516
bins[bin] += 1;
1617
}
1718
}

0 commit comments

Comments
 (0)