Sign extension in NSNumber / 10.4 SDK???
Sign extension in NSNumber / 10.4 SDK???
- Subject: Sign extension in NSNumber / 10.4 SDK???
- From: Thomas Engelmeier <email@hidden>
- Date: Thu, 17 Jul 2008 15:38:22 +0200
Hi,
I'm running into problems with [NSNumber numberWithUnsignedShort:
0x8000].
The following app returns the expected values when compiled against
the Leopard SDK.
Compiled against the 10.4 SDK, I get:
NSNumberTest[6058:813] 8000 (expected:8000) ffff8000 (expected:8000)
-32768 (expected:32768)
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSNumber *aNumber = [NSNumber numberWithUnsignedShort:0x8000];
NSLog(@"%x (expected:8000) %x (expected:8000) %@ (expected:32768)",
[aNumber unsignedShortValue],
[aNumber intValue],
[aNumber description]);
[pool drain];
return 0;
}
What are my best options to get around that? (Except of using the next
larger NSNumber variants to store unsigned values in order to prevent
unwanted sign expensions for unsigned values)?
TIA,
Tom_E
_______________________________________________
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