Solved

bigInteger to smaller number in java

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 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

18 Experts available now in Live!

Get 1:1 Help Now