UNPKG

@adguard/agtree

Version:
22 lines (21 loc) 614 B
/** * @file Utility for counting set bits in numbers. */ /** * Counts the number of set bits (1s) in a 32-bit number using Hamming Weight (SWAR) method. * * This is a fast bit counting algorithm that uses SWAR (SIMD Within A Register) technique. * It's significantly faster than string conversion methods and works in O(1) time. * * @param a Number to count bits in. * * @returns The number of bits set to 1. * * @example * ```typescript * getBitCount(0); // 0 * getBitCount(7); // 3 (0b111) * getBitCount(0xFF); // 8 (0b11111111) * ``` */ export declare function getBitCount(a: number): number;