[futurebasic] Re: [FB] Bit swapping

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

From: Paul Bruneau <paul_bruneau@...>
Date: Wed, 20 Oct 1999 10:54:43 -0400
I failed Digital Logic 250, but I think I'm safe on this tip:

If you perform an Exclusive Or with 255 on the bits you should be good.

Watch out not to do the XOR on a regular integer variable since it's 16
bits long, but if you do it on an 8 bit variable you'll be fine.

01000000 XOR
11111111
--------
10111111

It's a great graphics trick for cursors and stuff.

PB


Hans van Maanen wrote:
> 
> 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
> 
> --
> To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>