• 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: [newbie] numeric strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] numeric strings


  • Subject: Re: [newbie] numeric strings
  • From: Clark Cox <email@hidden>
  • Date: Wed, 16 Jun 2004 10:43:07 -0400

On Jun 16, 2004, at 10:14, Randall Meadows wrote:

> At 1:40 PM +0200 6/16/04, Robert Kuilman wrote:
>
>> Well,
>>
>> the NSString class has the
>> - intValue
>> - floatValue
>> - doubleValue
>>
>> selectors, which all return 0(.0) if the string not a valid
>> {int,float,double} value.
>
> Just out of curiousity, how does one distinguish between an "error"
> condition caused by the string "a1b2c3" and a valid input of "0",
> "0.0", or even "00000.000", all of which would return the value of 0
> or 0.0 (depending on the selector)?

If that distinction matters to you, then use some other way of
obtaining the value (like NSScanner). This is much like the difference
between atoi() and strtol() in the C library; The former is simple, but
doesn't handle error cases robustly, and the latter handles error
cases, is more customizable, but is slightly more complex.

--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://www.livejournal.com/users/clarkcox3/

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: [newbie] numeric strings (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: Reading the executable from the executable
  • Next by Date: EOF Cocoa Alternatives...
  • Previous by thread: Re: [newbie] numeric strings
  • Next by thread: Re: [newbie] numeric strings
  • Index(es):
    • Date
    • Thread