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


ranges of int and long same in my computer. why??

I am getting the same output for ranges of int and long in my computer(both give 2*10^9), but long long gives correct output. why is size of int as big as long? I use gcc 4.8.1 compiler

std::cout << "Minimum value for long long: " << std::numeric_limits<"long long>::min() << '\n';

std::cout << "Maximum value for long long: " << std::numeric_limits<long long>::max() << '\n';

so generally for numbers less than 10^9 I use int only, today I suffered because of this in the december cook-off

asked 22 Dec '14, 00:57

king_of_hacker's gravatar image

accept rate: 7%

Codechef uses sphere engine like spoj.
According to ideone (also running sphere engine),
int and long are both 4 bytes (32 bits) and long long int is 8 bytes or 64 bits (atleast in C).
Check this for more a demo on ideone (on gcc 4.8.1).
Also check the link by @betlista ♦♦, a good discussion is there.


answered 22 Dec '14, 01:27

mediocoder's gravatar image

accept rate: 36%

edited 22 Dec '14, 01:47

Because that's the way it is in C/C++, datatype sizes are not well defined as for example in Java -

signed long int - Not smaller than int. At least 32 bits.


answered 22 Dec '14, 01:05

betlista's gravatar image

3★betlista ♦♦
accept rate: 11%

what ranges does codechef have for int and long??

(22 Dec '14, 01:10) king_of_hacker3★

I do not know really, I'm using int and long long...

(22 Dec '14, 01:13) betlista ♦♦3★
According to this link, modern compiler i.e. For 32-bit and 64-bit compilers size of int and long is 4 bytes. But the main thing to note is that int and long are not same, because according to standard
The standard only requires ints to be stored in at least 16 bits, and longs in 32 bits.


answered 22 Dec '14, 18:44

rishabhprsd7's gravatar image

accept rate: 14%

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: 22 Dec '14, 00:57

question was seen: 3,783 times

last updated: 22 Dec '14, 18:44