• 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: "Ronnie B" <email@hidden>
  • Date: Tue, 2 Sep 2008 14:04:34 -0400

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?

On Tue, Sep 2, 2008 at 1:53 PM, Gregory Weston <email@hidden> wrote:

> Ronnie B wrote:
>
>  Hello,
>>
>> Is there an easy way to convert a decimal number to hexadecimal.
>> NSNumberFormatter does not have an api for that.  Any advice.
>>
>
> Depends on what you mean. The words "decimal" and "hexadecimal" don't have
> any implications beyond the presentation of data. In memory, integers don't
> have any particular base; they just "are." So if you've got a integer and
> want to display the hex representation of it, use something like NSString's
> stringWithFormat: with a format that includes the code %x. If you've got an
> NSString that represents a base 10 number, you can send it an intValue
> message, thus getting your input for stringWithFormat:.
> _______________________________________________
>
> 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
>
_______________________________________________

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

  • Prev by Date: Re: Problem with NSUserDefaultsController
  • Next by Date: Re: converting from decimal to hexadecimal
  • Previous by thread: Re: converting from decimal to hexadecimal
  • Next by thread: Re: converting from decimal to hexadecimal
  • Index(es):
    • Date
    • Thread