List of utility methods to do Bit Set
boolean | setBit(final byte[] buf, final long bitIndex, final boolean value) Set the value of a bit - this is NOT thread-safe (contention for the byte in the backing buffer can cause lost updates). final int mask = (1 << withinByteIndexForBit(bitIndex)); final int off = byteIndexForBit(bitIndex); byte b = buf[off]; final boolean oldValue = (b & mask) != 0; if (value) b |= mask; else b &= ~mask; ... |
int | setbit(final int num, final int bitnum, final boolean state) setbit return (state) ? (num | (1 << bitnum)) : (num & ~(1 << bitnum));
|
int | setBit(final int source, final int bit, final boolean value) Sets the specified bit to 1 if value parameter is true, unsets the bit otherwise. if (value) { return source | (1 << bit); return source & ~(1 << bit); |
long | setBit(final long word, final int idx, final boolean bit) set Bit if (bit) return setBitTo1(word, idx); return setBitTo0(word, idx); |
int | setBit(int b0, boolean value, int original) Sets n-th bit for the given integer if (getBit(b0, original) != value) { int mask = (1 << b0); return original ^ mask; return original; |
int | setBit(int bit) set Bit return (1 << bit);
|
int | setBit(int bitmask, int bit, boolean enabled) set Bit if (enabled) { int v = (int) Math.pow(2, bit); return bitmask | v; } else { return bitmask & ~bit; |
int | setBit(int bits, int index) Sets bit at index in bits to one. return bits | (1 << index);
|
int | setBit(int changeValue, int position, int value) set Bit int result = changeValue; int bt = (1 << position); if (value == 1) { result |= bt; } else { result &= (bt ^ 255); return result; ... |
int | setBit(int data, int bit, int value) Sets bit in a number if (value == 1) { data = data | (1 << bit); } else { data = data & ~(1 << bit); return data; |