Java Utililty Methods Number Unpack

List of utility methods to do Number Unpack

Description

The list of methods to do Number Unpack are organized into topic(s).

Method

int[]unpack64(long num)
Reversed the pack64() function
int a = (int) (num >>> 32);
int b = (int) num;
return new int[] { a, b };
byte[]unpackDigital(int packed)
unpack Digital
if (packed == 0)
    return new byte[16];
byte[] sig = new byte[16];
for (int i = 0; i < 16; i++)
    sig[i] = (byte) (((packed & 1 << i) == 0) ? 0 : 255);
return sig;
int[]unpackInt(final int argb, final int type)
unpack Int
int[] vals = null;
int p1 = 0;
int p2 = 1;
int p3 = 2;
int p4 = 3;
switch (type) {
case TYPE_RGB:
    vals = new int[3];
...
intunpackInt(int packedInt, int numBits, int numShiftedLeft)
unpack Int
int bitsUnshifted = (int) (Math.pow(2, numBits) - 1); 
int bitsShifted = bitsUnshifted << numShiftedLeft; 
int outputValue = packedInt & bitsShifted; 
return outputValue >> numShiftedLeft; 
intunpackInt(long theLong, boolean isFirst)
take a long
int result = 0;
if (isFirst) {
    theLong >>= 32;
result = (int) (theLong & 0xffffffff);
return result;
int[]unpackInts(long... longs)
unpack Ints
int len = 2 * longs.length;
int result[] = new int[len];
int i = 0;
for (long l : longs) {
    result[i++] = (int) (l & 0xffffffffL);
    result[i++] = (int) (l >> 32);
return result;
...
byte[]unpackKmer(final long value)
unpack Kmer
final int highest = (int) Long.numberOfTrailingZeros(Long.highestOneBit(value));
final int n = highest / BITS_PER_BASE + ((highest % BITS_PER_BASE) > 0 ? 1 : 0);
byte[] result = new byte[n];
for (int i = 0; i < n; i++) {
    final int bitOffset = i * BITS_PER_BASE;
    result[n - 1 - i] = (byte) ((value & (SINGLE_BASE_MASK << bitOffset)) >> bitOffset);
return result;
...
int[]unpackLong(long a, int bits)
Method unpackLong.
int m = 64 / bits;
int mval = (int) Math.pow(2, bits);
int[] result = new int[m];
long next;
for (int i = m; i > 0; i--) {
    next = a;
    a = a >> bits;
    result[i - 1] = (int) (next - (a * mval));
...