• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: bit/byte processing in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bit/byte processing in cocoa


  • Subject: Re: bit/byte processing in cocoa
  • From: Shawn Erickson <email@hidden>
  • Date: Thu, 13 Jan 2005 09:09:00 -0800


On Jan 13, 2005, at 8:58 AM, Bob Ippolito wrote:


On Jan 13, 2005, at 4:28, Shawn Erickson wrote:


On Jan 12, 2005, at 10:07 PM, Jon wrote:

I was wondering how to deal with bits/bytes in cocoa. How could I, say AND a char with another? Or XOR it, or use other things like shr/shl etc? Sorry for the newbie question, but I can't figure it out.

How you do it in C? Objective-C is a super set of C so anything you can do in C you can do in Objective-C.


(of course I am assuming you the C programming language)

I personally have no idea what "shr" or "shl" is nor much idea exactly what you are trying to do and how you are having problems with it (what of Cocoa are you using, etc.) so providing more information would be helpful.

shr and shl are (x86?) assembly mnemonics for shifting bits right and left respectively.

Ah now I know why I have heard of them but not what they did... of course PPC has different instructions and hence...


use regular 'ol C syntax.

As an example just in case you don't know C (get a book on it as needed)...


char inByte = 0xA5, outByte, mask = 0x0F;
outByte = inByte << 2; //shift it left two bits
outByte = inByte >> 5; //shift it right five bits (and sign extend)
outByte = inByte & mask; // bitwise and
outByte = inByte | mask; // bitwise or
outByte = inByte ^ mask; // bitwise xor

Also if you had some thing like...

outByte = outByte & mask;

...you could shorten it to...

outByte &= mask;

-Shawn

_______________________________________________
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


References: 
 >bit/byte processing in cocoa (From: Jon <email@hidden>)
 >Re: bit/byte processing in cocoa (From: Shawn Erickson <email@hidden>)
 >Re: bit/byte processing in cocoa (From: Bob Ippolito <email@hidden>)

  • Prev by Date: Re: bit/byte processing in cocoa
  • Next by Date: scrollable display/edit views
  • Previous by thread: Re: bit/byte processing in cocoa
  • Next by thread: Proxy User/Password *required* setting? Where is it?
  • Index(es):
    • Date
    • Thread