On Feb 3, 2011, at 3:05 PM, Jerry Krinock wrote: > Thanks, Glenn, and thanks, Matt, for the explanation. > > So I added a parameter to my method which one can use to get the performance > improvement only if they are willing to compromise accuracy and parsing of > numbers written in "e" notation. Also, I chose a name which is less likely > to used by Apple. >
Why not just use NSScanner's scanDouble: instead of trying to scan a string that you think is valid and then convert to a double? For example, if the input string is @"123.45-67.89" you'll end up scanning the entire string (which scanDecimal: or scanDouble: will only scan up through the "5"). Using scanDouble: will give you back support for scientific notation and consistent handling of "unexpected" strings, and all the other subtleness that can occur with floating point parsing (for example, you're code also misses handling things like "+123") Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com