Skip to content

Commit

Permalink
Fix division by zero bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Sep 7, 2023
1 parent 41f381f commit 26a93d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/align_rings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cpp11::integers find_splits_c(cpp11::doubles lengths, int n) {
splits[0] += n_remain;
break;
}
int split = std::round(n * lengths[j] / total);
int split = total == 0 ? n_remain : std::round(n * lengths[j] / total);
if (split == 0) split = 1;
split = split < n_remain ? split : n_remain;
splits[j] = split;
Expand Down

0 comments on commit 26a93d1

Please sign in to comment.