You are not logged in. Please login at to post your questions!


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.

asked 12 Jul '14, 22:50

tacoder's gravatar image

accept rate: 18%

edited 12 Jul '14, 22:52

This is the correct range in 32 bit.
The problem might be with the some intermediate result causing overflow.


answered 12 Jul '14, 23:04

pratku123's gravatar image

accept rate: 14%

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.

(12 Jul '14, 23:39) tacoder3★

Correct. Who down-voted this!?

(13 Jul '14, 15:43) bugkiller3★

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!


answered 12 Jul '14, 23:35

chalubhalu's gravatar image

accept rate: 6%

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

(13 Jul '14, 15:25) tacoder3★

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.

(13 Jul '14, 15:43) bugkiller3★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 12 Jul '14, 22:50

question was seen: 6,215 times

last updated: 13 Jul '14, 15:43