?
Solved

bigInteger to smaller number in java

Posted on 2011-03-16
3
Medium Priority
?
422 Views
Last Modified: 2013-11-13
hello, am trying to convert a very large  BigInteger into a more workable form in java.  the biginteger is about 20 lines long and i wanted to convert it into maybe a hex-decimal or a base 36 form.  is there any way to do that in java?   thank you in advance
0
Comment
Question by:gmakungo22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:enachemc
ID: 35145878
use java.math.BigInteger class
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 35150768
BigIntegers are stored in binary (or hex, however you want to look at it). It just displays it in decimal for you. If you think of the computer as working in bytes, then it basically stores it in base 256. If you want to store it in a file in this format, you just need to open the file in binary format. However, in the RAM it's already like that so you don't really have to do anything.
0
 
LVL 28

Accepted Solution

by:
dpearson earned 500 total points
ID: 35153944
You want to use the
BigInteger.toString(int radix)
method.

This will convert the BigInteger into a String using whatever base (radix) you would like.  For example, for hex you'd use:
BigInteger myBigInteger;
String hexString = myBigInteger.toString(16);

More here:
http://download.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html#toString%28int%29

Doug
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Progress
Starting up a Project

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question