diff --git a/matrix/helper_functions.hpp b/matrix/helper_functions.hpp index 9c85fcda82..37d2191f94 100644 --- a/matrix/helper_functions.hpp +++ b/matrix/helper_functions.hpp @@ -93,8 +93,9 @@ template Integer wrap(Integer x, Integer low, Integer high) { const auto range = high - low; - if (x < low) + if (x < low) { x += range * ((low - x) / range + 1); + } return low + (x - low) % range; }