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
}
}
结果:1000011
十进制转二进制
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
}
}
结果:55
八进制转十进制
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
}
}
结果:147
十六进制转八进制
????????通过以上例子发现没有,只需要修改对应的几进制转几进制就可以了,不需要记繁琐的内置函数。
|