• 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
Re: converting from decimal to hexadecimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: converting from decimal to hexadecimal


  • Subject: Re: converting from decimal to hexadecimal
  • From: Gregory Weston <email@hidden>
  • Date: Tue, 02 Sep 2008 14:08:36 -0400

On Sep 2, 2008, at 2:04 PM, Ronnie B wrote:

Ok. In my code I have this:
NSString *str = [NSString stringWithFormat:@"%x", [NSNumber numberWithInt:12345]];
NSLog(@" --- hex or not %@", str);


in a concole I see this:
--- hex or not 5c633d0

But, in Calculator.app I see this:  0x3039

What i am doing wrong?

You're passing a pointer to an object representing a numeric value, not the numeric value proper. If you want the integer from an NSNumber you'd have to send it an intValue (or similar) message.


NSString* str = [NSString stringWithFormat:@"%x", 12345];

should get you what you want.

_______________________________________________

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: converting from decimal to hexadecimal
      • From: "Ronnie B" <email@hidden>
References: 
 >Re: converting from decimal to hexadecimal (From: Gregory Weston <email@hidden>)
 >Re: converting from decimal to hexadecimal (From: "Ronnie B" <email@hidden>)

  • Prev by Date: Re: converting from decimal to hexadecimal
  • Next by Date: Re: Debugging NSWindow disappearances
  • Previous by thread: Re: converting from decimal to hexadecimal
  • Next by thread: Re: converting from decimal to hexadecimal
  • Index(es):
    • Date
    • Thread