[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSData, hex, and decimal
- Subject: NSData, hex, and decimal
- From: bwebster at mac.com (Brian Webster)
- Date: Fri Mar 15 12:18:01 2002
- In-reply-to: <200203152001.g2FK1Va13027@lists.omnigroup.com>
On Friday, March 15, 2002, at 02:01 PM, macosx-dev-
request@xxxxxxxxxxxxx wrote:
> Ok I'm reading packets of info from a server. I can decode
> them fine until
> I reach a strange barrier: 127.
>
> Why? As soon as I receive 0x80 and try to use this code I get negative
> numbers... Why is it doing this?
>
> [data getBytes:&packetLength range:NSMakeRange(2, 1)];
> NSLog(@"Length: %c %i data:%i",packetLength,packetLength, [data
> length]);
Try using %u instead of %i to print out an unsigned value
instead of a signed value.
--
Brian Webster
bwebster@xxxxxxx
http://homepage.mac.com/bwebster