bsr

Scans the bits in v from the most significant bit to the least significant bit, looking for the first set bit.

  1. int bsr(uint v)
    nothrow @safe @nogc pure
    int
    bsr
    (
    uint v
    )
  2. int bsr(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(bsr(0x21) == 5);
assert(bsr((ulong.max >> 15) - 1) == 48);

Meta