public final class BitUtils
extends java.lang.Object
BitUtils
class implements some methods for manipulating with bits.Modifier and Type | Method and Description |
---|---|
static java.math.BigInteger |
getBigIntegerMask(int width)
Returns the bit mask for the given width.
|
static java.math.BigInteger |
getBigIntegerMask(int lo,
int hi)
Returns the bit mask for the given range.
|
static java.math.BigInteger |
getField(java.math.BigInteger value,
int lo,
int hi)
Returns the field of the given value.
|
static int |
getField(int value,
int lo,
int hi)
Returns the field of the given value.
|
static long |
getField(long value,
int lo,
int hi)
Returns the field of the given value.
|
static int |
getIntegerMask(int width)
Returns a bit mask of the given width.
|
static int |
getIntegerMask(int lo,
int hi)
Returns a bit mask for the given range.
|
static long |
getLongMask(int width)
Returns the bit mask of the given width.
|
static long |
getLongMask(int lo,
int hi)
Returns the bit mask for the given range.
|
static java.math.BigInteger |
setField(java.math.BigInteger value,
int lo,
int hi,
java.math.BigInteger field)
Sets the field to the given value.
|
static int |
setField(int value,
int lo,
int hi,
int field)
Sets the field to the given value.
|
static long |
setField(long value,
int lo,
int hi,
long field)
Sets the field to the given value.
|
public static int getIntegerMask(int width)
width
- Mask width.public static int getIntegerMask(int lo, int hi)
lo
- Lower bound.hi
- Higher bound.public static int getField(int value, int lo, int hi)
value
- Value.lo
- Lower bound.hi
- Higher bound.public static int setField(int value, int lo, int hi, int field)
value
- Value.lo
- Lower bound.hi
- Higher bound.public static long getLongMask(int width)
width
- Mask width.Long
bit mask.public static long getLongMask(int lo, int hi)
lo
- Lower bound.hi
- Higher bound.Long
bit mask.public static long getField(long value, int lo, int hi)
value
- Value.lo
- Lower bound.hi
- Higher bound.public static long setField(long value, int lo, int hi, long field)
value
- Value.lo
- Lower bound.hi
- Higher bound.public static java.math.BigInteger getBigIntegerMask(int width)
width
- Mask width.BigInteger
bit mask.public static java.math.BigInteger getBigIntegerMask(int lo, int hi)
lo
- Lower bound.hi
- Higher bound.BigInteger
bit mask.public static java.math.BigInteger getField(java.math.BigInteger value, int lo, int hi)
value
- Value.lo
- Lower bound.hi
- Higher bound.public static java.math.BigInteger setField(java.math.BigInteger value, int lo, int hi, java.math.BigInteger field)
value
- Value.lo
- Lower bound.hi
- Higher bound.