How to compare 2 more than 30 digit number in java

Can i get the source code or logic to compare 2 more than 30 digit number?
gunjankhatriAsked:
Who is Participating?
 
InteractiveMindCommented:
Use the java.math.BigInteger class to store your numbers and compare them.
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html
0
 
basav_comCommented:
Can you elaborate your question more..
0
 
Thomas4019Commented:
You could turn them both into Strings and compare them with their equals() method.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
isarasooCommented:
Hi , I have a similar problem to this currently i got around it by loading the digits straight into a char array and then compare the outputs and it works but il rather have a simpler solution.

I tried the above methods suggesting to convert it to string, but that would only be possible if i can store the value as something initially i.e. long  num = 40 digits.

Just a question for InteractiveMind  how many digits can you assign to BigInteger.
sorry in advance if im not allowed to ask a counter question here

thanks
0
 
isarasooCommented:
I have just tested bigInteger class and it works fine for numbers over 30dig.  thanks InteractiveMind
0
 
Thomas4019Commented:
I am fairly sure BigInterger is designed to hold unlimited amount of digitis. It should just keep allocating more memory.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.