The reason is there is a maximum value that an integer can hold -- the maximum is declared in the header file limits.h that is supplied by your compiler. What you are seeing is called numeric overflow.
If you need bigger numbers then use a bigger integer, such as "long long", which holds about twice as many digits as an int or long. There are no standard C or C++ data types that will hold an infinite number of digits.
Ancient Dragon
Achieved Level 70
32,120 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 69
Question Answered as of 1 Year Ago by
Ancient Dragon