class Solution
{
public String toHex(int num)
{
if (num == 0){
return new String("0");
}
String Hex = new String("0123456789abcdef");
StringBuilder sb = new StringBuilder();
while (sb.length() < 8 && num != 0)
{
sb.append(Hex.charAt(0b1111 & num));
num >>= 4;
}
sb.reverse();
return new String(sb);
}
}
十进制转化为十六进制
最新推荐文章于 2024-08-30 22:25:46 发布