Java Bit Value Set bitIsSet(long value, long test)

Here you can find the source of bitIsSet(long value, long test)

Description

Checks if bits are set in a value.

License

Open Source License

Parameter

Parameter Description
value the value.
test the testing bits.

Return

true if all of the bits set in test are set in value, false otherwise.

Declaration

public static boolean bitIsSet(long value, long test) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2016 Black Rook Software
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 ******************************************************************************/

public class Main {
    /**//from   w  w w .  j a  v a 2s .  c  o  m
     * Checks if bits are set in a value.
     * @param value      the value.
     * @param test      the testing bits.
     * @return         true if all of the bits set in test are set in value, false otherwise.
     */
    public static boolean bitIsSet(long value, long test) {
        return (value & test) == test;
    }
}

Related

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