List of utility methods to do Bit Get
int | bitAt(byte b, int pos) bit At int i = 1 << 7 - pos; return (b & i & 0xFF) > 0 ? 1 : 0; |
boolean | bitAt(int offset, byte aByte) Examine the values of bits within a byte. return (aByte & (1 << offset)) != 0;
|
boolean | bitAt(int offset, byte aByte) bit At return (aByte & (1 << offset)) != 0;
|
int | bits(int i) bits return 32 - Integer.numberOfLeadingZeros(i);
|
int | bits(int i) Compute the integer logarithms (ceil(log(x+1)) of a value return 32 - Integer.numberOfLeadingZeros(i);
|
int | bits(int n, int offset, int length) Bit play http://stackoverflow.com/questions/11419501/converting-bits-in-to-integer n = n >> (31 - offset - length); int mask = ~(-1 << length); return n & mask; |
String | bits(int value, int c) bits StringBuffer sb = new StringBuffer(); for (int i = c - 1; i >= 0; i--) { int bv = (value >>> (8 * i)) & 0xff; sb.append('['); for (int j = 7; j >= 0; j--) { sb.append((bv & (1 << j)) > 0 ? '1' : '0'); sb.append(']'); ... |
int | bits(int value, int first, int last) Get the specified bits from the specified value. return (value >> last) & mask(first - last + 1);
|
int | bits(long maxValue) bits int bits = 0; while (maxValue != 0) { bits++; maxValue >>>= 1; return bits; |
long | bits(long value, int sb, int eb) Extracts a bit range from a long value value >>>= eb; sb -= eb - 1; long mask = (1L << sb) - 1; value &= mask; return value; |