bsf

Scans the bits in v starting with bit 0, looking for the first set bit.

  1. int bsf(uint v)
    nothrow @safe @nogc pure
    int
    bsf
    (
    uint v
    )
  2. int bsf(ulong v)

Return Value

Type: int

The bit number of the first bit set. The return value is undefined if v is zero.

Examples

assert(bsf(0x21) == 0);
assert(bsf(ulong.max << 39) == 39);

Meta