Re: fast bit rotation
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Dec 31, 2003
- 476 views
Another thing you could try is to build tables of pre-computed shifts, eg: sequence shl, shr shl=repeat(0,256) shr=repeat(0,256) for i = 0 to 255 do if i<=127 then shl[i+1]=i*2 else shl[i+1]=and_bits(i,#7F)*2+1 end if shr[shl[i+1]+1]=i end for Use k=shl[k+1] when k is 0..255, to avoid zero index problems. You can do your own test/timings, though I got 3.9 million/sec on a 233MHz PII with 48Mb ram, sorry Tommy, CNR ) Pete PS No warranty on the above code, btw.