0 is not a power of 2
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 19 13:09:23 PDT 2015
On 5/19/15 4:01 PM, deadalnix wrote:
> Have you tried things like :
>
> (x >> bsr(x)) == 1 ?
>
> I have no idea if this is faster or not, but worth trying.
Hm.. I think this would always succeed. Perhaps you mean:
1 << bsr(x) == x;
And ironically, still doesn't work for 0 :D
IIRC, bsr is a binary search (even when it's an instruction), I doubt
it's as fast as subtraction and logic-and.
-Steve
More information about the Digitalmars-d
mailing list