Reputation: 21
In this program I need to be able to take a String and convert it into a base from (2-36) by using BigInteger
I'm new to java and I'm trying to find a way to use base conversion by using BigInteger instead of the method below. Although this works as intended, I'd like some tips on how to simplify it. For this project I'm unable to use the built-in base conversion functions in Integer or BigInteger.
Here is my conversion below.
public static String convertInteger(String theValue, int initialBase, int finalBase) {
BigInteger bigInteger = new BigInteger(theValue,initialBase);
String value = bigInteger.toString(finalBase);
value = value.toUpperCase();
return value;
}
}
Upvotes: 2
Views: 1418