Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:54:51+00:00 2026-06-12T18:54:51+00:00

so I want to convert NSString to double. I found the following example: NSString

  • 0

so I want to convert NSString to double. I found the following example:

NSString * s = @"1.5e5";
NSLog(@"%lf", [s doubleValue]);

It works but if doubleValue cannot convert the string to double it simply returns 0.0 which is not what I need. I need some method that tries to convert a string representation of double to double and if indicate somehow if it can’t be converted.
c# has an excellent method

double d;
boolean Double.TryParse(str, out d)

Is there any method similar to the above one in Objective C? or maybe it’s better to use regex? however, i don’t really know how to do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:54:53+00:00Added an answer on June 12, 2026 at 6:54 pm

    You can use the NSScanner class:

    NSString *s = @"1.5e5";
    NSScanner *scanner = [NSScanner scannerWithString:s];
    double d;
    BOOL success = [scanner scanDouble:&d];
    

    If you want to ensure that the entire string has been scanned (no extra characters after the number), use

    BOOL isAtEnd = [scanner isAtEnd];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSString with string like hello. Now I want to convert the
I want to convert NSDate to NSString? How's that possible? I tried this, but
I have an NSString object and want to convert it into a std::string .
Hi I want to convert the NSString into Byte array. if I have string
I want to convert the following NSString to a NSDate : @2013-04-01T22:00:00Z I am
I want to convert NSString to NSDate but UIPickerView shows current datedatePicker=[[UIDatePicker alloc]init]; datePicker.userInteractionEnabled=YES;
I want to convert ABRecord to string textfield.text=(NSString *)(ABRecordGetRecordID(ref)); how can i do it.
i want to convert a short string to md5 hash , I found several
I want to convert NSString into NSDate. So I tried following code : NSDateFormatter
Possible Duplicate: NSString to NSDate Hi I want to convert the string OCT 1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.