Java Integer to Boolean intToBooleanArray(int in)

Here you can find the source of intToBooleanArray(int in)

Description

convet an int into an array of 32 booleans 1 per bit

License

Apache License

Parameter

Parameter Description
in a parameter

Declaration

public static boolean[] intToBooleanArray(int in) 

Method Source Code

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

public class Main {
    /**/*from  w  w  w  .j  a v a  2s. com*/
     * convet an int into an array of 32 booleans
     * 1 per bit
     * @param in
     * @return
     */
    public static boolean[] intToBooleanArray(int in) {
        boolean[] ret = new boolean[32];
        int index = 1;
        for (int i = 0; i < ret.length; i++) {
            if ((in & index) != 0)
                ret[i] = true;
            index <<= 1;
        }
        return ret;
    }
}

Related

  1. intToBool(int int_in, int length)
  2. intToBoolAra(int num, int len)
  3. intToBoolean(int x)
  4. intToBoolean(int[] values)
  5. intToBoolean(Integer value)