- public class chaBiaoFa {
- /**
- * 查表法
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- toHex(60);
- System.exit(0);
- }
- public static void toHex(int num){
- char[] arr = new char[8];
- int p = arr.length;
- char[] chs = {'0','1','2','3'
- ,'4','5','6','7'
- ,'8','9','A','B'
- ,'C','D','E','f'};
- while(num!=0) {
- int tmp = num&15;
- arr[--p] = chs[tmp];
- num >>>=4;
- }
- for(int i = p;p<arr.length;p++){
- System.out.print(arr[i]);
- }
- }
- }
复制代码 为什么我的输出结果是 |
|