public String conv(String number, int startBase, int endBase){
if(startBase > 16 || endBase > 16) return "BASE ERROR";
char NUMS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
String result = "";
int temp = 0;
int x;
boolean found = false;
for(int i = 0; i < number.length(); i++){
for(x = 0; x < startBase; x++){
if(NUMS[x] == number.charAt(number.length()-(i+1))){
found = true;
break;
}
}
if(!found) return "NUMBER ERROR";
temp += (x*power(startBase, i));
}
do{
result += NUMS[temp%endBase];
temp /= endBase;
}while(temp != 0);
return new StringBuilder(result).reverse();
}
public long power(int num, int pow){
if(pow == 0) return 1;
return num*power(num, pow-1);
}