On 14/07/2009, at 3:02 PM, Chase Meadors wrote:

for (int i = 0;  i < aNumber;  i ++) {

        NSLog(@"%02X", buf[i]);

}

This is what's really bothering me because I'll get normal bytes, like 2E 00 AA, but sometimes, seemingly randomly, there are six leading F's. Something like:

0E
00
FFFFFF8E


%X expects an unsigned number but you are passing it a char, which is signed, so it's sign extending and displaying the result as if the high bit were a sign bit. You'll notice it's not random, it's whenever the high bit is set.

Also, your buf should be declared char*, not char, which is why it's crashing.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to