Static
changeChange bit according to given value on data from index
changeBit(1, 0, false); // returns 0(dec)
// 0000 0001 data
// 1111 1110 mask ~
// ---------------- AND
// 0000 0000 x1
//
// 0000 0000 state
// 0000 0001 mask
// ---------------- AND
// 0000 0000 x2
//
// 0000 0000 (x1)
// 0000 0000 (x2)
// ---------------- OR
// 0000 0000 result
Unsigned integer value
Unsigned integer value (0..7)
Static
clearSet bit false on data from index
clearBit(1, 0); // returns 0(dec)
// 0000 0001 mask
//
// 0000 0001 data
// 1111 1110 ~mask
// ---------------- AND
// 0000 0000 result
Unsigned integer value
Unsigned integer value (0..7)
Static
getTransforms a position (1..n) to byte index and inner bit position
getByteNoAndBitPos(1); // returns { byteNo: 0, bitPos: 0}
getByteNoAndBitPos(256); // returns { byteNo: 31, bitPos: 7}
when position is <= 0
Unsigned integer value (1..n)
Static
hasChecks if all logical "1" bits from byte2 compare to the ones in byte1
// 1. 0101 0010 (82 dec)
// 2. 0100 0010 (66 dec)
// ------------- AND
// 0100 0010 (66 dec)
// 66 dec === 66 dec :-)
//
// 1. 0010 1100 (44 dec)
// 2. 0010 1000 (40 dec)
// ------------- AND
// 0010 1000 (40 dec)
// 40 dec === 40 dec :-)
// 1. 0000 0000 (0 dec)
// 2. 0001 0000 (16 dec)
// -------------- AND
// 0000 0000 (0 dec)
// 0 dec !== 16 dec :-(
// 1. 0000 0000 (0 dec)
// 2. 0010 0010 (34 dec)
// -------------- AND
// 0000 0000 (0 dec)
// 0 dec !== 34 dec :-(
Static
hasCompare 2 bytes, matches when byte1 has any similar bits set compared to byte2
// 1. 1000 1001
// 2. 0000 1000
// ------------- AND
// 0000 1000 (8 dec)
// (8 dec !== 0x0) => true
const byte1 = 0x89; // 137 (dec)
const byte2 = 0x8; // 8 (dec)
hasAnyBits({byte1, byte2}); // returns true
Static
isCheck if bit is set false on index
isFalse(13, 2); // returns false
// 0000 1101 data
//
// 0000 0011 data (after data >>= index)
// 0000 0001
// ---------- AND
// 0000 0001 === 0000 0000 (false)
//
Unsigned integer value
Unsigned integer value (0..7)
Static
isCheck if bit is set true on index
isTrue(13, 2); // returns true
// 0000 1101 data
//
// 0000 0011 data (after data >>= index)
// 0000 0001
// ---------- AND
// 0000 0001 === 0000 0001 (true)
//
Unsigned integer value
Unsigned integer value (0..7)
Static
setSet bit true on data from index
setBit(0, 1); // returns 1
// 0000 0000 data
// 0000 0001 mask
// ---------------- OR
// 0000 0001 result
Unsigned integer value
Unsigned integer value (0..7)
Static
toggleToggle (inverse) bit value on data from index
toggleBit(1, 0); // Returns 0(dec)
// 0000 0001 mask
// 0000 0001 data
// --------------- XOR
// 0000 0000 result
Unsigned integer value
Unsigned integer value (0..7)
Generated using TypeDoc
This is the Gibbon Processor which does all the bit masking, nothing special ;)