How to tell java that this number can become long at runtime?

I am running this code where the number may turn out to be too large to be an integer.

I define this number:

long num = 0L;

at the very beginning, but still, when it gets too big, for example 99999999991, it cannot be so big, it would be something like 1410065408.

My question is, how can I tell the java compiler that this number can get too large, just make it long during calculation?

Thanks in advance!

+4
source share
1 answer

you need to use BigInteger , it takes up dynamic memory, so it has no limit.

+4
source

Source: https://habr.com/ru/post/1692519/


All Articles