标签:oid images code ati 进制转换 span es2017 alt hex
public static void toHex(int num,int base,int offset){ if(num==0){ System.out.print("0");
return;
} char[] chs={‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘, ‘7‘,‘8‘,‘9‘,‘A‘,‘B‘,‘C‘, ‘D‘,‘E‘,‘F‘}; char[] arr = new char[8]; int pos = arr.length; while(num!=0){ int temp = num & base; arr[--pos] = chs[temp]; num = num >>> offset; } for(int i=pos;i<arr.length;i++){ System.out.print(arr[i]); } }
使用位运算,不断取二进制的后4位。
标签:oid images code ati 进制转换 span es2017 alt hex
原文地址:http://www.cnblogs.com/guoyunhao/p/7689262.html