int 打印成32位

public class Temp {


    public static void print(int num) {

        for (int i = 31; i >= 0; i--) {
            System.out.print(((num & (1 << i)) == 0 ? "0" : "1"));
        }
        System.out.println();


    }

    public static void main(String[] args) {


        int num = 4;

        print(4);
    }
}

 

posted @ 2022-01-22 17:42  AngDH  阅读(57)  评论(0编辑  收藏  举报