You are not logged in. Please login at www.codechef.com 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

2★tacoder
5174615
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.

link

answered 12 Jul '14, 23:04

pratku123's gravatar image

3★pratku123
1.8k4931
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) tacoder2★

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!

link

answered 12 Jul '14, 23:35

chalubhalu's gravatar image

4★chalubhalu
2902411
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) tacoder2★

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
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×52
×18

question asked: 12 Jul '14, 22:50

question was seen: 5,134 times

last updated: 13 Jul '14, 15:43