0

Isn't this a end loop due to int limit overflow

for( int i =0; i >= 0; i++)

7th Jan 2018, 10:13 AM
Erkan Bayram
Erkan Bayram - avatar
2 odpowiedzi
+ 13
Technically, yes. The loop will end when i overflows and becomes a negative value. Compiling and running this on desktop shows that it takes around 8 seconds for this to happen. Code Playground may timeout before that.
7th Jan 2018, 10:32 AM
Hatsy Rei
Hatsy Rei - avatar
+ 9
yes , it's end with overflow where the condition is being false with negative i value integer type max value is 2,147,483,647 in 32-bit signed equal to (2^31)-1 and after overflow it's become -2,147,483,648
7th Jan 2018, 10:51 AM
ZeroByte
ZeroByte - avatar