Re: Sign extension in NSNumber / 10.4 SDK???
Re: Sign extension in NSNumber / 10.4 SDK???
- Subject: Re: Sign extension in NSNumber / 10.4 SDK???
- From: Jens Alfke <email@hidden>
- Date: Thu, 17 Jul 2008 12:01:03 -0700
On 17 Jul '08, at 10:18 AM, Thomas Engelmeier wrote:
Thanks for confirming. I'll probably end up writing enhancement
requests to documentation so this behavior gets documented.
You can do that, but I really doubt the 10.4 documentation is still
being updated! I guess it could be added to the current docs as
something like "In 10.4 and below, the following incorrect behavior
could occur..."
Sean McBride wrote:
Interesting. What about NSKeyedArchiver? It has, for example,
encodeInt32:forKey: but no unsigned equivalent. What should one do if
one wants to encode a uint32? Are there sign extension dangers here?
It shouldn't be a problem as long as you call the matching decode
method (-decodeInt32ForKey:). You'll get back the same 32 bits you put
in. However, it could cause trouble if you read the archive using -
decodeInt64ForKey:, and assign the result to a 64-bit int, because in
that case you'll definitely get negative numbers out when you put in
large UInt32s with the high bit set.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden