public class Bits extends Object
| Constructor and Description |
|---|
Bits() |
| Modifier and Type | Method and Description |
|---|---|
static int |
bitOffset(long n) |
static int |
branchingBit(long a,
long b) |
static int |
highestBit(int n) |
static long |
highestBit(long n) |
static boolean |
isPowerOfTwo(long n) |
static int |
log2Ceil(long n) |
static int |
log2Floor(long n) |
static int |
lowestBit(int n) |
static long |
lowestBit(long n) |
static long |
maskAbove(int bits) |
static long |
maskBelow(int bits) |
static long |
slice(long n,
int start,
int end) |
static boolean |
test(int n,
int offset) |
static boolean |
test(long n,
int offset) |
public static int bitOffset(long n)
n - a number, which must be a power of twopublic static long lowestBit(long n)
n - a numberpublic static int lowestBit(int n)
n - a numberpublic static long highestBit(long n)
n - a numberpublic static int highestBit(int n)
n - a numberpublic static int log2Floor(long n)
n - a numberpublic static int log2Ceil(long n)
n - a numberpublic static boolean test(int n,
int offset)
n - a numberoffset - the offset of the bit being testedpublic static boolean test(long n,
int offset)
n - a numberoffset - the offset of the bit being testedpublic static long maskBelow(int bits)
bits - a bit offsetpublic static long maskAbove(int bits)
bits - a bit offsetpublic static int branchingBit(long a,
long b)
a and bpublic static boolean isPowerOfTwo(long n)
n - a numberpublic static long slice(long n,
int start,
int end)