Package gnu.math
Class BitOps
java.lang.Object
gnu.math.BitOps
Implements logical (bit-wise) operations on infinite-precision integers.
There are no BitOps object - all the functions here are static.
The semantics used are the same as for Common Lisp.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IntNumReturn the logical (bit-wise) "and" of an IntNum and an int.static IntNumReturn the logical (bit-wise) "and" of two IntNums.static intbitCount(int i) static intbitCount(int[] x, int len) static intCount one bits in an IntNum.static IntNumDo one the the 16 possible bit-wise operations of two IntNums.static booleanReturn the value of a specified bit in an IntNum.static IntNumExtract a bit-field as an unsigned integer.static IntNumReturn the logical (bit-wise) "(inclusive) or" of two IntNums.static intlowestBitSet(int i) static intstatic IntNummakeMask(int startBit, int endBit) Create a mask with bits true form bits form startBit to endBit.static IntNumReturn the logical (bit-wise) negation of an IntNum.static IntNumreverseBits(IntNum x, int start, int end) static voidDo one the the 16 possible bit-wise operations of two IntNums.static IntNumsetBitValue(IntNum x, int bitno, int newValue) Set the value of a specified bit in an IntNum.static intshift(int x, int count) static longshift(long x, int count) static intshiftUnsigned(int x, int count) static longshiftUnsigned(long x, int count) static intswappedOp(int op) Return the boolean opcode (for bitOp) for swapped operands.static booleanReturn true iff an IntNum and an int have any true bits in common.static booleanReturn true iff two IntNums have any true bits in common.static IntNumReturn the logical (bit-wise) "exclusive or" of two IntNums.
-
Method Details
-
bitValue
Return the value of a specified bit in an IntNum. -
setBitValue
Set the value of a specified bit in an IntNum. -
test
Return true iff an IntNum and an int have any true bits in common. -
test
Return true iff two IntNums have any true bits in common. -
and
Return the logical (bit-wise) "and" of an IntNum and an int. -
and
Return the logical (bit-wise) "and" of two IntNums. -
ior
Return the logical (bit-wise) "(inclusive) or" of two IntNums. -
xor
Return the logical (bit-wise) "exclusive or" of two IntNums. -
not
Return the logical (bit-wise) negation of an IntNum. -
swappedOp
public static int swappedOp(int op) Return the boolean opcode (for bitOp) for swapped operands. I.e. bitOp (swappedOp(op), x, y) == bitOp (op, y, x). -
bitOp
Do one the the 16 possible bit-wise operations of two IntNums. -
setBitOp
Do one the the 16 possible bit-wise operations of two IntNums. -
makeMask
Create a mask with bits true form bits form startBit to endBit. -
extract
Extract a bit-field as an unsigned integer. -
lowestBitSet
public static int lowestBitSet(int i) -
lowestBitSet
-
bitCount
public static int bitCount(int i) -
bitCount
public static int bitCount(int[] x, int len) -
bitCount
Count one bits in an IntNum. If argument is negative, count zero bits instead. -
reverseBits
-
shift
public static int shift(int x, int count) -
shiftUnsigned
public static int shiftUnsigned(int x, int count) -
shift
public static long shift(long x, int count) -
shiftUnsigned
public static long shiftUnsigned(long x, int count)
-