看下下面的注释部分吧
- public class Shiliu {
- public static void getshiliu(int a) {
-
- /*
- * .....1010 1010 1010 1010 a >>>无符号向右移四位
- * 1111 & 15
- * 1010 x
- *
- *
- * */
- for (; a > 0; a = a >>> 4) {
- int x = a & 15;
- if (x > 9) //大于9的数就要转换成A B C D E F
- System.out.print((char) (x - 10 + 'A'));
- else
- System.out.print(x);
- }
- }
- public static void main(String[] args) {
- int n = 165695845;
- getshiliu(n);
- }
- }
复制代码 |