• 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: Int Val of Hex From NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Int Val of Hex From NSData


  • Subject: Re: Int Val of Hex From NSData
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Mon, 10 Mar 2003 10:32:55 -0500

On Monday, Mar 10, 2003, at 10:05 US/Eastern, Seth Willits wrote:

If I have an NSData object that has three bytes in it (A9B), how can I get the integer equivalent (2715)?

I'm assuming that you actually mean 3 bytes (and not 3 hex characters)

This should do it:

const unsigned char *bytes = [nsData bytes]
unsigned int value;

NSAssert([nsData length] >= 3);
value = bytes[0] << 16 | bytes[1] << 8 | bytes[2];



--
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Int Val of Hex From NSData
      • From: Seth Willits <email@hidden>
References: 
 >Int Val of Hex From NSData (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Need guidance in table sorting
  • Next by Date: Re: NSTableView with scrollbars does not update correctly
  • Previous by thread: Int Val of Hex From NSData
  • Next by thread: Re: Int Val of Hex From NSData
  • Index(es):
    • Date
    • Thread