Solved

bigInteger to smaller number in java

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …
Simple Linear Regression

696 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