geotic
Version:
entity-component-system
18 lines (13 loc) • 315 B
JavaScript
const ONE = 1n;
export const subtractBit = (num, bit) => {
return num & ~(1n << bit);
};
export const addBit = (num, bit) => {
return num | (ONE << bit);
};
export const hasBit = (num, bit) => {
return (num >> bit) % 2n !== 0n;
};
export const bitIntersection = (n1, n2) => {
return n1 & n2;
};