import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger b = new BigInteger("67", 10);
System.out.println(b.toString(2)); //1000011
}
}
Result: 1000011
Decimal to Binary
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger b = new BigInteger("67", 8);
System.out.println(b.toString(10)); //55
}
}
Result: 55
Octal to Decimal
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger b = new BigInteger("67", 16);
System.out.println(b.toString(8)); //147
}
}
Results: 147
Hexadecimal to Octal
Through the above examples, it is found that there is no, you only need to modify the corresponding number to convert the number, and you don't need to memorize the cumbersome built-in functions.