Java Integer to Bit convertIntToBits(int num)

Here you can find the source of convertIntToBits(int num)

Description

convert Int To Bits

License

Open Source License

Declaration

public static String convertIntToBits(int num) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String convertIntToBits(int num) {
        StringBuilder builder = new StringBuilder();
        while (num != 0) {
            if ((num & 0x1) == 1)
                builder.insert(0, '1');
            else//from   w  w  w.ja v  a2  s  .  co m
                builder.insert(0, '0');
            num >>>= 1;
        }
        return builder.toString();
    }
}

Related

  1. convertIntToBitsWithPadding(int num)
  2. intToBits(int in, int min, int max, int numBits)
  3. intToBits(int n, int size)
  4. intToBits(int no)