Java Bit String From toBits(long value, int length)

Here you can find the source of toBits(long value, int length)

Description

transform a long value into a boolean array

License

Apache License

Parameter

Parameter Description
value a parameter
length a parameter

Declaration

public static boolean[] toBits(long value, int length) 

Method Source Code

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

public class Main {
    /**/*from w w  w .ja va 2s  .  co m*/
     * transform a long value into a boolean array
     * @param value
     * @param length
     * @return
     */
    public static boolean[] toBits(long value, int length) {

        boolean[] bits = new boolean[length];
        for (int i = length - 1; i >= 0; i--) {
            bits[i] = (value & (1 << i)) != 0;
        }
        return bits;
    }
}

Related

  1. toBit(byte value, int index)
  2. toBitMask(int numBits)
  3. toBits(final byte b)
  4. toBits(int b)
  5. toBits(int b)
  6. toBitsArray(byte[] bytes, int bitCount)
  7. toBitString(byte value)
  8. toBitString(byte[] bytes)
  9. toBitString(byte[] bytes)