import { msb_lut_de_bruijn } from "./msb_lut_de_bruijn.js";

/**
 * Get index of the least significant set bit
 * Also known as ctz32 or "count trailing zeroes"
 * @see https://graphics.stanford.edu/~seander/bithacks.html
 * @param {number} v
 * @returns {number}
 */
export function lsb_32(v) {
    return msb_lut_de_bruijn[((v & -v) * 0x077CB531) >>> 27];
}