Java Bit Get bitAt(int offset, byte aByte)

Here you can find the source of bitAt(int offset, byte aByte)

Description

Examine the values of bits within a byte.

License

Apache License

Parameter

Parameter Description
offset A zero indexed offset for the bits in the byte. [0,7]
aByte An input byte.

Return

The bit value of the byte at the given offset.

Declaration

public static boolean bitAt(int offset, byte aByte) 

Method Source Code

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

public class Main {
    /**//from w  ww.jav  a 2 s .c o  m
     * Examine the values of bits within a byte.
     *
     * @param offset A zero indexed offset for the bits in the byte. [0,7]
     * @param aByte An input byte.
     * @return The bit value of the byte at the given offset.
     */
    public static boolean bitAt(int offset, byte aByte) {
        return (aByte & (1 << offset)) != 0;
    }
}

Related

  1. bitAt(byte b, int pos)
  2. bitAt(int offset, byte aByte)
  3. bits(int i)
  4. bits(int i)
  5. bits(int n, int offset, int length)