Iosevka/font-src/support/util/mask-bit.mjs
2022-07-17 00:37:03 -07:00

10 lines
284 B
JavaScript

const pcNibbleLookup = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4];
export function maskBit(x, y) {
return x & (1 << y);
}
export function maskBits(x, y) {
return x & y;
}
export function popCountByte(x) {
return pcNibbleLookup[x & 0x0f] + pcNibbleLookup[(x >>> 4) & 0x0f];
}