Reputation: 29
After using class BigInteger my program on platform showed Memory Limit Exceeded.
Upvotes: -4
Views: 189
Reputation: 3300
Long can handle that value. You should remember to type an L after the value. For example:
long value = 12000000000L;
In the other hand, there is no limit for the BigInteger in theory due to it allocates the memory amount it needs, the limit is the available memory. You need to keep in mind BigInteger class is inmutable, so if you call add, multiply, divide or whatever it will return a new BigInteger instead of modifying the current one. You may consider to implement your own data structure according to your needs. And also you may consider to post your code.
Upvotes: 1
Reputation: 356
The maximal value a long can save (Long.MAX_VALUE) is 9,223,372,036,854,775,807
. As you say you want to save a number equal to 12,000,000,000
it should be totally possible to save it using a long, because your number is still much smaller that Long.MAX_VALUE...
Upvotes: 1