Java Integer to Binary intToBinary(int i)

Here you can find the source of intToBinary(int i)

Description

int To Binary

License

Apache License

Declaration

private static char[] intToBinary(int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    private static char[] intToBinary(int i) {
        char[] values = new char[32];
        for (int pos = 31; pos >= 0; pos--, i >>= 1) {
            if ((i & (int) 0x01) == (int) 1)
                values[pos] = '1';
            else//from  ww  w  .  ja  va2s.co  m
                values[pos] = '0';
        }
        return values;
    }
}

Related

  1. integerToBin(int value)
  2. integerToBinaryString(int value)
  3. integerToBinaryString(int value, int numberOfBits)
  4. integerToBinString(final int aValue, final int aFieldWidth)
  5. intToBinary(int binary, int digits)
  6. intToBinary(int i, int byteLength)
  7. intToBinary(long value, int bits)
  8. intToBinString(int val, int width)
  9. itob(int i, int j)