How to add two numbers of any length in java?
Say for example, in java long size is 64 bit. So the maximum range is -9223372036854775808 to 9223372036854775807. Am i
You can use a BigInteger.
BigInteger a = new BigInteger("9223372036854775807"); BigInteger b = new BigInteger("9223372036854775808"); BigInteger result = a.add(b);
The BigInteger will let you work with numbers of any size, but you lose a considerable amount of performance over long or int.
BigInteger
long
int