Java Bit Value Set bitIsSet(int x, int pos)

Here you can find the source of bitIsSet(int x, int pos)

Description

Determines whether a particular bit is set in the binary representation of an integer.

License

Open Source License

Parameter

Parameter Description
x The integer to be queried.
pos The bit to be queried.

Return

true if the bit as position pos is set.

Declaration

static boolean bitIsSet(int x, int pos) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /** //from w ww.  j  av  a  2s  .c  o m
     * Determines whether a particular bit is set in the binary representation
     * of an integer.
     * @param x The integer to be queried.
     * @param pos The bit to be queried.
     * @return <code>true</code> if the bit as position <code>pos</code> is set.
     */
    static boolean bitIsSet(int x, int pos) {
        return (x & (1 << pos)) != 0;
    }
}

Related

  1. bit_marker(String attribute, String type, int maxBits, int bit, boolean on)
  2. bit_marker_flexint(String attribute, int bit, boolean on)
  3. bit_marker_geohash(String attribute, int bit, boolean on)
  4. bitIsSet(byte data, byte bit)
  5. bitIsSet(int i, int offset)
  6. bitIsSet(long value, long test)
  7. bitSet(byte b, int pos)
  8. bitSet(int value, int bitmask)
  9. bitSet(long holder, int i, boolean set)