Checked_ sum() for all types that have both iter::Sum and checked_add()

I meant counting just the overflows in the i64 so that overflow up can cancel overflow down.

The point is that the argument that 1.8×1019 additions in a loop to overflow a counter will take "decades" to run is not necessarily true. They can run faster than that when the compiler is smart.

1 Like

Sorry I misread your previous comment.

In your counter example the optimizer removes the iterations altogether. In my post I said "if you're adding using that many iterations" specifically to mean that the iterations actually are there in the generated code, but clearly that qualifier wasn't enough and didn't work. My point was not to provide a robust implementation idea, but to say that arbitrarily large integers are not required or helpful.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.