+ 1

why it is giving output as "-638011199" for int x = 12246890689;

please help me

19th Apr 2018, 7:31 AM
Rahul Kaurav
Rahul Kaurav - avatar
2 Answers
+ 11
I'm assuming this is for C++? An int can hold values up to approximately 2.1 billion. Using a value higher than that overflows the int into negative values. The data type that can hold 12.2 billion is "long long int", which can hold a maximum of 9.2 quintillion. Keep in mind, not all compilers have that type. The Code Playground does, though.
19th Apr 2018, 7:42 AM
Tamra
Tamra - avatar
0
thanks for ur suggestion Jan Markus .but i can't escape until i get it completely.
19th Apr 2018, 8:34 AM
Rahul Kaurav
Rahul Kaurav - avatar