• 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: NSString to Integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString to Integer


  • Subject: Re: NSString to Integer
  • From: Jonathan Hess <email@hidden>
  • Date: Sat, 7 Mar 2009 20:37:10 -0800

When using a 64-bit architecture, Mac OS X uses 32 bit integers, but 64 bit longs. NSInteger is defined as a long for 64, not an integer.

When running 64-bit, you need to use %ld as the format option.

Try this and see if it works any beter:

	NSInteger d = [@"43253234929732" integerValue];
	NSLog(@"%qi, %ld", (long)d, (long)(d%2));

Good Luck -
Jon Hess

On Mar 7, 2009, at 5:41 PM, Sean McBride wrote:

Dave DeLong (email@hidden) on 2009-03-07 7:55 PM said:

I'm on a 2GHz Macbook Unibody, so I'm expecting that d is a 64-bit
integer.

Don't expect, measure. What does sizeof(d) give?

Also, if you want a 64 bit integer, use int64_t. NSInteger changes size
depending, as others have said.


Sean


_______________________________________________

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: NSString to Integer
      • From: Shawn Erickson <email@hidden>
References: 
 >NSString to Integer (From: Dave DeLong <email@hidden>)
 >Re: NSString to Integer (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: NSArrayController -- will change selection? --> tableView shouldSelectRow invoked twice
  • Next by Date: Re: Trying to understand the cause of a "message sent to deallocated instance" error
  • Previous by thread: Re: NSString to Integer
  • Next by thread: Re: NSString to Integer
  • Index(es):
    • Date
    • Thread