# How to deal with big integer class?

/* Sqrt.java    11/12/03
it squares each previous squared result*/
import java.text.*;
import java.math.*;
import java.math.BigInteger;
public class Sqrt{
public static void main(String[] args){
long[] square = new  long[10];
int ct;
square[0]= 2*2;
for(ct = 1; ct < 10; ct++)
square[ct] = (long)Math.pow(square[ct-1], 2);
for(int ct1 = 0; ct1 < 10; ct1++)
System.out.println(square[ct1]);
}
}
---------------------------------------------------------------------------------
Output:
4
16
256
65536
4294967296
9223372036854775807 (its actual result should be:18446744073709551616
9223372036854775807 (actual:3.4028236692093846346337460743177e+38)
9223372036854775807(actual:1.1579208923731619542357098500866e+77)
9223372036854775807(actual:1.3407807929942597099574024998193e+154)
9223372036854775807(actual:1.7976931348623159077293051907852e+308)

Although I declared the data type as Long, it doesn`t output the right results since they`re out of the range that Long can handle.What kind of data type can handle those sort of humongous numbers?

###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Quid, Me Anxius Sum?  Illegitimi non carborundum.Commented:

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
new output:
4.0
16.0
256.0
65536.0
4.294967296E9
1.8446744073709552E19
3.4028236692093846E38
1.157920892373162E77
1.3407807929942597E154
Infinity
suggestion appreciated
Quid, Me Anxius Sum?  Illegitimi non carborundum.Commented:
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.