Android进阶

【Android】 2进制、10进制、16进制互相转换

2019-11-14  本文已影响0人  urkay
//二进制转10进制
String two = "0001";
int ten = Integer.parseInt(two, 2);
//10进制转二进制
int ten = 10;
String two = Integer.toBinaryString(ten);
//10进制转16进制
int ten = 10;
String sixteen = Integer.toHexString(ten);
//16进制转10进制
String sixteen = "A6";
int ten = Integer.parseInt(sixteen, 16);
//二进制转16进制
String two = "0001";
int ten = Integer.parseInt(two, 2);
String sixteen = Integer.toHexString(ten);
//16进制转二进制
String sixteen = "A6";
int ten = Integer.parseInt(sixteen, 16);
String two = Integer.toBinaryString(ten);
上一篇下一篇

猜你喜欢

热点阅读