Re: Arbitrary length ints from NSData

2009-08-13 Thread Chase Meadors
On Aug 13, 2009, at 1:50 PM, Quincey Morris wrote: On Aug 13, 2009, at 11:25, Chase Meadors wrote: I'm afraid you'll have to explain the multiply-by-256-and-add technique. I mean something like this (untested): unsigned char *bytes = [self bytes]; int byteIndex = [self le

Re: Arbitrary length ints from NSData

2009-08-13 Thread Quincey Morris
On Aug 13, 2009, at 11:25, Chase Meadors wrote: I'm afraid you'll have to explain the multiply-by-256-and-add technique. I mean something like this (untested): unsigned char *bytes = [self bytes]; int byteIndex = [self length]; int result = 0; BOOL firstByte

Re: Arbitrary length ints from NSData

2009-08-13 Thread Alastair Houghton
On 13 Aug 2009, at 19:25, Chase Meadors wrote: I'm a hobby programmer, and my first experience with programming was the currency converter w/ interface builder example. As such, I guess I'm learning "from the top down." I'm not very familiar with straight C as I am with Objective-C. I'm afr

Re: Arbitrary length ints from NSData

2009-08-13 Thread Chase Meadors
On Aug 13, 2009, at 1:17 PM, Quincey Morris wrote: On Aug 13, 2009, at 10:34, Chase Meadors wrote: In other words, I might read one piece of data that is one byte: . I would want this to be read as -2. However, the current method would make the string "0xFE", then scan it to 0x00FE,

Re: Arbitrary length ints from NSData

2009-08-13 Thread Quincey Morris
On Aug 13, 2009, at 10:34, Chase Meadors wrote: In other words, I might read one piece of data that is one byte: . I would want this to be read as -2. However, the current method would make the string "0xFE", then scan it to 0x00FE, which is completely different. I might then read a p

Arbitrary length ints from NSData

2009-08-13 Thread Chase Meadors
Hi All, I'm having a problem reading numbers from some raw data I need to read. The data encodes numbers in little-endian format. I am defining a category on NSData to accomplish this. - (NSNumber *)interpretAsSingleNumber { NSMutableString *hexString = [NSMutableString str