Reputation: 1379
input:
BigInteger l = BigInteger.valueOf(111111111111111110);
compiler error message
Integer number too large
My objective is to continuously decrement of the given large number till a certain value(say K).
How can I achieve this?
Upvotes: 2
Views: 1978
Reputation: 56469
Integer number too large
the reason why it's giving an error is because the type that you've passed into the argument of the valueOf(...)
is an int
(this is the default type unless you specify otherwise) which has a limit, and you've exceeded this limit hence the error.
BigInteger l = BigInteger.valueOf(111111111111111110); // argument is int, so it will give a compiler error
use a long
argument instead.
BigInteger value = BigInteger.valueOf(111111111111111110L);
or use a string
argument.
BigInteger value = new BigInteger("111111111111111110");
Upvotes: 8