This code handles the case where count is rounded incorrectly (`count = to!size_t((end - beg) / step))`).