List of utility methods to do Bit Set
void | SetBit(byte _bitset, byte bit) Set Bit _bitset |= bit; |
byte | setBit(byte _byte, int position, boolean value) Sets a bit in the byte position--; return (byte) (value ? _byte | 1 << position : _byte & ~(1 << position)); |
void | setBit(byte a, int pos, boolean set) set byte a's pos'th bit if (true == set) { a = (byte) (a | (1 << pos)); } else { a = (byte) (a & ~(1 << pos)); |
byte | setBit(byte b, int i) set Bit return (byte) logicalOR(b, bitMask(i)); |
byte | setBit(byte b, int pos) set Bit return (byte) (b | (1 << pos)); |
byte | setBit(byte data, byte bit, boolean value) set Bit if (value) { data = (byte) (data | (1 << bit)); } else { data = (byte) (data & ~(1 << bit)); return data; |
byte | setBit(byte data, int bitNumber, boolean value) set Bit if (bitNumber < 0 || bitNumber > 7) throw new IllegalArgumentException("bitNumber out of range"); return (byte) setBit(data & 0xFF, bitNumber, value); |
byte | setBit(byte data, int bitPos, boolean on) set Bit if (bitPos < 1 || bitPos > 8) { throw new IllegalArgumentException("parameter 'bitPos' must be between 1 and 8. bitPos=" + bitPos); if (on) { return data |= 1 << (bitPos - 1); } else { return data &= ~(1 << (bitPos - 1)); |
byte | setBit(byte data, int pos, int val) Set one bit in a byte at the specified position with the specified bit value. int posBit = pos % 8; return (byte) ((val << (8 - (posBit + 1))) | data); |
byte | setBit(byte in, int position, boolean value) set Bit if (!value) { return (byte) (in & (0xFF ^ 1 << 8 - position)); } else { return setBit(in, position); |