Java Boolean From toBooleanArray(byte a, boolean[] buf)

Here you can find the source of toBooleanArray(byte a, boolean[] buf)

Description

Turns the requested byte into a binary based boolean array with a length of 8.

License

Apache License

Parameter

Parameter Description
a - The byte to convert.
buf - The boolean array to store the data in. Must be a length of at least 8.

Declaration

public static void toBooleanArray(byte a, boolean[] buf) 

Method Source Code

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

public class Main {
    /**/*from   w  w  w.  j  a v  a 2 s  . c  o  m*/
     * Turns the requested byte into a binary based boolean array with a length of 8. Each digit of the binary code indicated
     * each boolean in the array. For example, a binary value of 10011001 would return the values of "true, false, false, true,
     * true, false, false, true."
     * @param a - The byte to convert.
     * @param buf - The boolean array to store the data in. Must be a length of at least 8.
     */
    public static void toBooleanArray(byte a, boolean[] buf) {
        buf[0] = (a & 128) == 128;
        buf[1] = (a & 64) == 64;
        buf[2] = (a & 32) == 32;
        buf[3] = (a & 16) == 16;
        buf[4] = (a & 8) == 8;
        buf[5] = (a & 4) == 4;
        buf[6] = (a & 2) == 2;
        buf[7] = (a & 1) == 1;
    }
}

Related

  1. toBoolean(String value, boolean defaultValue)
  2. toBoolean(String value, boolean defaultValue)
  3. toBoolean(String value, boolean defaultValue)
  4. toBoolean(StringBuilder value)
  5. toBooleanA(byte[] data)
  6. toBooleanArray(byte[] array)
  7. toBooleanArray(byte[] byteArray)
  8. toBooleanArray(byte[] data)
  9. toBooleanArray(final E[] array)