[futurebasic] Re: [FB] Bit swapping

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1999 : Group Archive : Group : All Groups

From: Peter Bancroft <pbancroft@...>
Date: Thu, 21 Oct 1999 09:42:33 +1000
You could make an array of 0-255 elements. 256 total.

64 becomes the address. The contents are 2.
192 becomes an address. The contents are 3.

Also 0 becomes 0 and 255 becomes 255 if I read you right.

Precalculate the contents. Then during processing there is no calculation
overhead, just lookup overhead. Not sure what the speed of lookups are
though.

What are you actually using this for?

Peter

>Hi --
>
>What would be the fastest way to swap eight bits, so that e.g. 64 becomes 2
>(01000000 <> 00000010) and 192 becomes 3 (11000000 <> 00000011)?
>
>Can this be done without a loop FOR i = 0 to 3 et cetera?
>
>Any takers?
>
>Thanks! --
>
>Hans van Maanen