in reply to Re^5: Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
in thread Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
Unfortunately, the bitpatterns you generate -- in common with those used by grimey's code -- are not compatible with vec.
By way of example, this generates a vector with a single length 1x0 run, and a single length 2x0 run; and single length 3x0 run; and so on:
$vec = ''; $n=-1; vec( $vec, $n+=$_, 1 ) = 1 for 2 .. 17; print unpack 'b*', $vec;; 0100100010000100000100000010000000100000000100000000010000000000100000 +000000100000000000010000000000000100000000000000100000000000000010000 +0000000000001000... # 2 5 9 14 20 27 35 44 54 65 + 77 90 104 119 135 + 152
Thus, a search for
Running your code looking for these runs against that vector produces:
wrog 1: 0 wrog 2: 14 wrog 3: 5 wrog 4: 14 wrog 5: 14 wrog 6: 20 wrog 7: 27 wrog 8: 35 wrog 9: 44 wrog 10: 54 wrog 11: 65 wrog 12: 77 wrog 13: 90 wrog 14: 90 wrog 15: 90 wrog 16: 90 wrog 17: 90
I believe this is because little-endian bytes are bytes swapped and word swapped relative to big-endian.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
by wrog (Friar) on Jun 08, 2013 at 02:52 UTC | |
by BrowserUk (Patriarch) on Jun 08, 2013 at 06:20 UTC | |
by wrog (Friar) on Jun 08, 2013 at 11:37 UTC |