Solved

bigInteger to smaller number in java

Posted on 2011-03-16
3
395 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
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 26

Accepted Solution

by:
dpearson earned 125 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now