Build 1.0_r1(from source)

java.math
Class BitLevel

java.lang.Object
  extended by java.math.BitLevel

 class BitLevel
extends Object

Static library that provides all the bit level operations for BigInteger. The operations are:

All operations are provided in immutable way, and some in both mutable and immutable.


Method Summary
(package private) static int bitCount(BigInteger val)
           
(package private) static int bitLength(BigInteger val)
           
(package private) static BigInteger flipBit(BigInteger val, int n)
          Performs a flipBit on the BigInteger, returning a BigInteger with the the specified bit flipped.
(package private) static void inplaceShiftRight(BigInteger val, int count)
          Performs val >>= count where val is a positive number.
(package private) static boolean nonZeroDroppedBits(int numberOfBits, int[] digits)
          Check if there are 1s in the lowest bits of this BigInteger
(package private) static BigInteger shiftRight(BigInteger source, int count)
           
(package private) static boolean shiftRight(int[] result, int resultLen, int[] source, int intCount, int count)
          Shifts right an array of integers.
(package private) static boolean testBit(BigInteger val, int n)
          Performs a fast bit testing for positive numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bitLength

static int bitLength(BigInteger val)
See Also:
BigInteger.bitLength()

bitCount

static int bitCount(BigInteger val)
See Also:
BigInteger.bitCount()

testBit

static boolean testBit(BigInteger val,
                       int n)
Performs a fast bit testing for positive numbers. The bit to to be tested must be in the range [0, val.bitLength()-1]


nonZeroDroppedBits

static boolean nonZeroDroppedBits(int numberOfBits,
                                  int[] digits)
Check if there are 1s in the lowest bits of this BigInteger

Parameters:
numberOfBits - the number of the lowest bits to check
Returns:
false if all bits are 0s, true otherwise

shiftRight

static BigInteger shiftRight(BigInteger source,
                             int count)
See Also:
BigInteger.shiftRight(int)

inplaceShiftRight

static void inplaceShiftRight(BigInteger val,
                              int count)
Performs val >>= count where val is a positive number.


shiftRight

static boolean shiftRight(int[] result,
                          int resultLen,
                          int[] source,
                          int intCount,
                          int count)
Shifts right an array of integers. Total shift distance in bits is intCount * 32 + count.

Parameters:
result - the destination array
resultLen - the destination array's length
source - the source array
intCount - the number of elements to be shifted
count - the number of bits to be shifted
Returns:
dropped bit's are all zero (i.e. remaider is zero)

flipBit

static BigInteger flipBit(BigInteger val,
                          int n)
Performs a flipBit on the BigInteger, returning a BigInteger with the the specified bit flipped.

Parameters:
intCount: - the index of the element of the digits array where the operation will be performed
bitNumber: - the bit's position in the intCount element

Build 1.0_r1(from source)

Please submit a feedback, bug or feature