+ 1
why it is giving output as "-638011199" for int x = 12246890689;
please help me
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.
0
thanks for ur suggestion Jan Markus .but i can't escape until i get it completely.