Re: Cocoa and bit handling
Re: Cocoa and bit handling
- Subject: Re: Cocoa and bit handling
- From: Stephane Sudre <email@hidden>
- Date: Tue, 21 Dec 2004 14:57:09 +0100
On 21 déc. 04, at 12:27, Peter Karlsson wrote:
Dear list!
I have 2 pointers declared as byte. They are called source and target.
The source pointer points to the first byte of a memory area. The
target
pointer points to the first byte of another memory area.
Is there a easy way to move bits fom source byte to target byte?
Example:
Source byte maybe looks like this:
01001011
Target byte looks like this before:
00000000
Target byte looks like this after:
01000000
I want to move bit 3 of the source byte to bit 6 of the target byte.
This
will repeat thousands of times in a loop. And the bit position changes
every lap. So next lap I maybe want to move source bit 2 to target bit
5
and so on...
maskSource=(1<<bitSource);
maskDestination==(1<<bitDestination);
target= (target & ~ maskDestination) + (((source & maskSource)>>
bitSource)<< bitDestination);
probably
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden