Java Binary Encode toBinaryArray(int input, int length)

Here you can find the source of toBinaryArray(int input, int length)

Description

Returns an integer converted to a binary array.

License

Open Source License

Parameter

Parameter Description
input a parameter
length a parameter

Declaration

public static boolean[] toBinaryArray(int input, int length) 

Method Source Code

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

public class Main {
    /**/*from  w w  w.  j  a v a  2  s .c om*/
     * Returns an integer converted to a binary array.
     * @param input
     * @param length
     * @return
     */
    public static boolean[] toBinaryArray(int input, int length) {
        boolean[] bits = new boolean[length];
        for (int i = length - 1; i >= 0; i--) {
            bits[i] = (input & (1 << i)) != 0;
        }
        return bits;
    }
}

Related

  1. toBinary(int value, int bits)
  2. toBinary(long l, int bits)
  3. toBinary(long v, int len)
  4. toBinary(short value)
  5. toBinaryAddress(int index, int maxIndex)
  6. toBinaryArray(int integer, int size)
  7. toBinaryBoolean(boolean source)
  8. toBinaryChar(boolean bit)
  9. toBinaryClassName(String fileName)