You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
giving a count of 2 rather than 1. The errors are with
(((x ^ needles).wrapping_sub(LO)) & !x & HI) >> 7
Firstly, this should be
let x = x ^ needles;
((x.wrapping_sub(LO)) & !x & HI) >> 7
Secondly, this doesn't actually work for counting - the x.wrapping_sub(LO) sets the high bit correctly but can overflow into the next value if the next byte is 1 - wrapping_sub will decrement that to zero and the subtraction will continue past.
It's fairly simple to deal with by using
!((((v & !HI) + !HI) | v) >> 7) & LO
instead, but it'd be interesting to see if you don't have to spend the extra operations to get that. It doesn't seem to affect speed all too much, though.
The text was updated successfully, but these errors were encountered:
This test fails
giving a count of 2 rather than 1. The errors are with
Firstly, this should be
Secondly, this doesn't actually work for counting - the
x.wrapping_sub(LO)
sets the high bit correctly but can overflow into the next value if the next byte is 1 -wrapping_sub
will decrement that to zero and the subtraction will continue past.It's fairly simple to deal with by using
instead, but it'd be interesting to see if you don't have to spend the extra operations to get that. It doesn't seem to affect speed all too much, though.
The text was updated successfully, but these errors were encountered: