二进制数的直接表示

在java中可以使用Integer和Long类的静态方法toBinaryString()来表示二进制数。

1 public class Literals {
2 
3     public static void main(String[] args) {
4         // TODO Auto-generated method stub
5   int i = 0x2f;
6   System.out.println("i:" + Integer.toBinaryString(i));
7     }
8 
9 }


结果:i:101111
原文地址:https://www.cnblogs.com/huxianlu/p/3332436.html