What is the range of int?



Should int be able to hold <10^9 values?

Int ranges from –2,147,483,648 to 2,147,483,647.

I was solving a question but i got WA and then i got AC after changing all int’s to long long int.
Can’t discuss the specific problem as it is in ongoing contest.

What i mean to ask is whether codechef’s compiler has less range of an int.


This is the correct range in 32 bit.

The problem might be with the some intermediate result causing overflow.


The problem might have been caused maybe because you were performing an operation like m=(n*n-1)/2
In this case though both n and n-1 are in int range but teh value of m might exceed the int range and hence result in wa due to overflow!


Codechef compiler also works on 32 bit?

The weird thing is i don’t do any operations on the integers in the code.

Guess i’ll have to wait for contest to end so i can post my solution code as well.


As i said, i don’t do any operations on the integers, so overflow is not a possibility


Correct. Post the problem and your solution, if there was a WA due to overflow calculations might be a culprit, else the reason is not overflow but something else.


Correct. Who down-voted this!?