Package ru.ispras.fortress.util
Class BitUtils
- java.lang.Object
-
- ru.ispras.fortress.util.BitUtils
-
public final class BitUtils extends java.lang.Object
BitUtils
class implements some methods for manipulating with bits.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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 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 java.math.BigInteger
getField(java.math.BigInteger 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 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.static java.math.BigInteger
setField(java.math.BigInteger value, int lo, int hi, java.math.BigInteger field)
Sets the field to the given value.
-
-
-
Method Detail
-
getIntegerMask
public static int getIntegerMask(int width)
Returns a bit mask of the given width.- Parameters:
width
- Mask width.- Returns:
- Integer bit mask.
-
getIntegerMask
public static int getIntegerMask(int lo, int hi)
Returns a bit mask for the given range.- Parameters:
lo
- Lower bound.hi
- Higher bound.- Returns:
- Integer bit mask.
-
getField
public static int getField(int value, int lo, int hi)
Returns the field of the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.- Returns:
- Value field.
-
getField
public static long getField(long value, int lo, int hi)
Returns the field of the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.- Returns:
- Value field.
-
getField
public static java.math.BigInteger getField(java.math.BigInteger value, int lo, int hi)
Returns the field of the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.- Returns:
- Value field.
-
setField
public static int setField(int value, int lo, int hi, int field)
Sets the field to the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.field
- Field.- Returns:
- Value with the updated field.
-
setField
public static long setField(long value, int lo, int hi, long field)
Sets the field to the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.field
- Field.- Returns:
- Value with the updated field.
-
setField
public static java.math.BigInteger setField(java.math.BigInteger value, int lo, int hi, java.math.BigInteger field)
Sets the field to the given value.- Parameters:
value
- Value.lo
- Lower bound.hi
- Higher bound.field
- Field.- Returns:
- Value with the updated field.
-
getLongMask
public static long getLongMask(int width)
Returns the bit mask of the given width.- Parameters:
width
- Mask width.- Returns:
Long
bit mask.
-
getLongMask
public static long getLongMask(int lo, int hi)
Returns the bit mask for the given range.- Parameters:
lo
- Lower bound.hi
- Higher bound.- Returns:
Long
bit mask.
-
getBigIntegerMask
public static java.math.BigInteger getBigIntegerMask(int width)
Returns the bit mask for the given width.- Parameters:
width
- Mask width.- Returns:
BigInteger
bit mask.
-
getBigIntegerMask
public static java.math.BigInteger getBigIntegerMask(int lo, int hi)
Returns the bit mask for the given range.- Parameters:
lo
- Lower bound.hi
- Higher bound.- Returns:
BigInteger
bit mask.
-
-