Range of Long long int in c++

Jul 21, 2014 at 5:58pm
#include <iostream>

int main ()
{ long long int n=10000000000; // 9223372036854775801

cout<<n<<endl;
return 0;
}


This code shows error message as: "integer constant too large for "long" type, but since the max range of long long int is 9223372036854775801. I'm unable to understand the reason for the error?
I'd be very happy if you help me out with this

Thanks in advance!
Jul 21, 2014 at 5:59pm
The maximum limit for long long int is 9223372036854775807 and not 9223372036854775801, sorry for that, but that still doesn't explain the error message. :/
Jul 21, 2014 at 6:04pm
Your code displays the correct number for me, what compiler are you using? Try doing n = 10000000000LL;
Last edited on Jul 21, 2014 at 6:07pm
Jul 21, 2014 at 6:22pm
It works now, What does that LL in the end signify? When it should be used in a code?

PS: I'm using Dev C++ 4.9.9.2, which one are you using?
Last edited on Jul 21, 2014 at 6:23pm
Jul 21, 2014 at 7:09pm
What does that LL in the end signify?

see tutorial page: http://www.cplusplus.com/doc/tutorial/constants/



Please don't use Dev C++ 4.9.9.2. it was last updated in 2005 and is no longer updated.

Consider instead:
http://www.codeblocks.org/
or
http://orwelldevcpp.blogspot.com/

Jul 21, 2014 at 7:22pm
Thanks a lot! :)
Jul 21, 2014 at 8:21pm
Ok, So I downloaded the latest Dev Cpp compiler, But I am facing the following error while compiling the code:

http://i60.tinypic.com/2ilbvh4.jpg ( Click on the image in the middle )

Please help!
Jul 21, 2014 at 8:27pm
No, It is fixed now.
Topic archived. No new replies allowed.