What is the range of int?

int
range

#1

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.


#2

This is the correct range in 32 bit.

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


#3

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!


#4

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.


#5

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


#6

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.


#7

Correct. Who down-voted this!?