×

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

 0 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::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 204●3●12 accept rate: 7%

 2 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 1.1k●3●13 accept rate: 36%
 1 Because that's the way it is in C/C++, datatype sizes are not well defined as for example in Java - http://www.cplusplus.com/doc/tutorial/variables/ signed long int - Not smaller than int. At least 32 bits. answered 22 Dec '14, 01:05 16.9k●49●115●225 accept rate: 11% what ranges does codechef have for int and long?? (22 Dec '14, 01:10) I do not know really, I'm using int and long long... (22 Dec '14, 01:13)
 1 http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.90%29.aspx 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 1.9k●1●11●41 accept rate: 14%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×274
×53
×29
×24

question asked: 22 Dec '14, 00:57

question was seen: 3,829 times

last updated: 22 Dec '14, 18:44