Re: fastest transition from bitmask to the position of it's lowest SET bit
- From: "jason.cipriani@xxxxxxxxx" <jason.cipriani@xxxxxxxxx>
- Date: Thu, 29 May 2008 07:33:32 -0700 (PDT)
On May 29, 9:40 am, Lars Uffmann <a...@xxxxxxxxxxxxxx> wrote:
For example:
V = b0110101000110010 (2 bytes)
M = b0000011111110000 (2 bytes)
O = ln (16) / ln (2) = 4
P = b0110101000110010
AND b0000011111110000
SHR 4
= b0000001000110000 SHR 4 = b0000000000100011 = b100011 (= d35)
Now I am quite at a loss to determine that order O in a single
mathematical operation other than the logarithm.
You want (V & M) / (M & -M):
V = b0110101000110010
M = b0000011111110000
-M = b1111100000010000 <-- 2's complement
M&-M = b0000000000010000 <-- lowest bit on
V&M = b0000001000110000 <-- masked
/M&-M = b0000000000100011 <-- divide is like shr low_bit_pos
Jason
.
- Follow-Ups:
- Re: fastest transition from bitmask to the position of it's lowest SET bit
- From: Lars Uffmann
- Re: fastest transition from bitmask to the position of it's lowest SET bit
- From: jason.cipriani@xxxxxxxxx
- Re: fastest transition from bitmask to the position of it's lowest SET bit
- References:
- fastest transition from bitmask to the position of it's lowest SET bit
- From: Lars Uffmann
- fastest transition from bitmask to the position of it's lowest SET bit
- Prev by Date: Re: view son this program
- Next by Date: Re: view son this program
- Previous by thread: fastest transition from bitmask to the position of it's lowest SET bit
- Next by thread: Re: fastest transition from bitmask to the position of it's lowest SET bit
- Index(es):