public class Bits extends Object
Note that for bitwise AND, OR, XOR of integer values etc you can use
 the java bitwise operators
 "&", "|", "^".
| Modifier and Type | Method and Description | 
|---|---|
static int | 
bitCount(long i)
Returns the number of set bits in the 64-bit two's complement
 representation of the integer argument. 
 | 
static int | 
fromBinary(String binVal)
Converts a string representing a binary number to its integer value. 
 | 
static boolean | 
hasBit(long value,
      int bitIndex)
Determines whether a given integer has a certain bit set to 1. 
 | 
static String | 
toBinary(long value)
Converts the integer argument to a binary string consisting
 only of 1s and 0s. 
 | 
public static boolean hasBit(long value,
                             int bitIndex)
value - integer whose bits are to be testedbitIndex - index of bit to be tested in range 0..63,
                     where 0 is the least significant bit(value & 1L<<bitIndex) != 0public static int bitCount(long i)
i - integer valueipublic static String toBinary(long value)
value - integer valuevaluepublic static int fromBinary(String binVal)
binVal - binary representation of valuebinValCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.