bvin
public class Test {

    public static void main(String[] args){
        
        int i = 1;
        String s = toFullBinaryString(i);//整形打印出二进制整形
        System.out.println(s);
        System.out.println(Integer.parseInt(s));//将二进制转换成整形
    }
    
    
    
    private static String toFullBinaryString(int x) {
        int[] buffer = new int[Integer.SIZE];//Integer是32位的
        
        for (int i = (Integer.SIZE - 1); i >= 0; i--) {
            buffer[i] = x >> i & 1;
        }
        String s = "";
        for (int j = (Integer.SIZE - 1); j >= 0; j--) {
            s = s + buffer[j];
        }
        return s;
    }
    
}

分类:

技术点:

相关文章:

  • 2021-12-17
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-08-09
  • 2021-12-01
猜你喜欢
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
相关资源
相似解决方案