List of utility methods to do Bit Flip
int | flip(int i) Flips the byte order of an integer int result = 0; result |= (i & 0xFF) << 24; result |= (i & 0xFF00) << 8; result |= ((i & 0xFF0000) >> 8) & 0xFF00; result |= ((i & 0xFF000000) >> 24) & 0xFF; return result; |
int | flip(int value) flip return value ^ Integer.MIN_VALUE;
|
long | flip(long a) A (self-inverse) bijection which converts the ordering on unsigned longs to the ordering on longs, that is, a <= b as unsigned longs if and only if flip(a) <= flip(b) as signed longs. return a ^ Long.MIN_VALUE;
|
int | flipBitAsBinaryString(int flipBit) flip Bit As Binary String return 1 << flipBit;
|
byte | flipBitAt(int bitIndex, byte b) bitIndex from right to left (0 = least significant = rightmost bit) return (byte) ((int) b ^ (1 << (bitIndex & 31))); |
void | flipBits(byte[] bytes, int start, int bitLength) flip Bits for (int i = 0; i < bitLength / 2; i++) { boolean leftBit = getBit(bytes, start * 8 + i); boolean rightBit = getBit(bytes, start * 8 + bitLength - i - 1); setBit(bytes, start * 8 + i, rightBit); setBit(bytes, start * 8 + bitLength - i - 1, leftBit); |
int | flipBits(int n) flip Bits System.out.println("n = " + Integer.toBinaryString(n)); int mask = 0; for (int i = 0; i < 31; i++) { mask <<= 1; if (i % 2 == 0) mask |= 1; System.out.println("mask = " + Integer.toBinaryString(mask)); ... |
int | flipBits(int value) flip Bits return ~value;
|
long | flipC(long v, int off) Invert bit number "off" in v. v ^= (1L << off);
return v;
|
int | FLIPENDIAN_INT32(int x) FLIPENDIAINT return (x << 24) | (x >>> 24) | ((x & 0x0000ff00) << 8) | ((x & 0x00ff0000) >> 8);
|