Here you can find the source of toBinaryArray(int input, int length)
Parameter | Description |
---|---|
input | a parameter |
length | a parameter |
public static boolean[] toBinaryArray(int input, int length)
//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; } }