How can I represent and use a large number in Java? In scientific computing there are a number of times that I need numbers to be greater than a long.
Asked
Active
Viewed 106 times
-1
dimo414
- 44,897
- 17
- 143
- 228
lacksledge
- 1
- 1
2 Answers
0
You should use BigInteger for this..
They can be as large as you need - until you run out of memory.
eg:
BigInteger Bigintvar1 = new BigInteger("1234567890123456890");
BigInteger Bigintvar2 = new BigInteger("2743561234");
Bigintvar1 = Bigintvar1.add(Bigintvar2);
Sarath
- 2,268
- 1
- 11
- 24
-
I have tried it. thanks – lacksledge Jul 03 '15 at 08:28