Well I asked my CPU to double check. If I got the code right it thinks that
ffs(i^(i-1))==fls(i) is true for 1->2^32-1
If you think about it it seems to make sense
x-1 turns the lowest 100..0 sequence into 01......1
The xor removes unchanged higher bits
so
10100
-1 10011
XOR 00111
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/