I am wondering how I could expect if the next iteration will generate integer overflow when calculating factorial F or not?
Let's say that at each iteration I have int I, and the maximum value is MAX_INT.
That sounds like homework, I know. Not this. I just ask myself "stupid" questions.
Adding
At least about this, given several BITS (the width that an integer can take in bits), I could round the number i to the next power of two and determine whether the left shift will exceed BITS. But how will it look algorithmically?
source
share