• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Sign extension in NSNumber / 10.4 SDK???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Sign extension in NSNumber / 10.4 SDK???
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Concurrent network transmission
  • Next by Date: Re: notification when app is moved
  • Previous by thread: Re: Concurrent network transmission
  • Next by thread: Re: Sign extension in NSNumber / 10.4 SDK???
  • Index(es):
    • Date
    • Thread