Re: fast bit rotation

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 blink)

Pete
PS No warranty on the above code, btw.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu