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

  • Home
  • SEARCH
  • 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 8513361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:32:41+00:00 2026-06-11T04:32:41+00:00

I am trying to convert a string to a double value to use it

  • 0

I am trying to convert a string to a double value to use it as a coordinate in an annotation.

I need the double value to have 5 decimal places to be placed on the map.

Let’s say the string is hello and the double I need is whatsup.

The format of the string is exactly the way I want it and I want to make it a double, so I use the doublevalue property of the string.

NSString *hello = @"12.61655";
double whatsup = hello.doubleValue;
NSLog(@"%f",whatsup); //this gives 12.616550 WITH A ZERO in the end
NSLog(@"%.5f",whatsup); //This gives me the correct value of 12.61655 with only 5 decimal places

So now if I want to write:

coordinate.latitude = whatsup 

it gives the double with the extra zero.

How can I write

coordinate.latitude = SOMETHING HERE 

which is the double with only 5 decimal places?
Can I implement the “%.5f” here somehow?

Have tried the numberformatter but it gives me an NSnumber. I need a double:

I am using this code in a for loop to plot the annotations (pins).

When i use the same forloop with doubles I hardcode it works fine. But when I use this code to get the values from the csv file, I dont get any pins:

double latitudeFromCSV = [[components objectAtIndex:0] doubleValue];
double longitudeFromCSV = [[components objectAtIndex:1] doubleValue];
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = latitudeFromCSV;
annotationCoord.longitude = longitudeFromCSV;
  • 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-11T04:32:43+00:00Added an answer on June 11, 2026 at 4:32 am

    Check out the NSString method -stringWithFormat:

    But to make it good you’ll need to remove the leading zeros as you can’t know there will be no value like @”12.50000″.


    NSNumberFormatter * nf = [[NSNumberFormatter new] autorelease];
    nf.maximumFractionDigits = 5;
    NSLog(@"%@", [nf stringFromNumber:[NSNumber numberWithFloat:@"12.61655f".doubleValue]]);
    

    should give you 12.61655 as an output string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert a string to a double value in .Net 3.5. Quite
I'm trying to convert a string value to Double but I sill get error
I'm trying to convert a string to a double value but it's not returning
I'm trying to convert std::string to float/double . I tried: std::string num = 0.6;
I am trying to convert a string to a double. The code is very
I am trying to convert a string value into a name of an attribute
I'm currently trying to take a string (0.1) and convert it to a double
I'm trying to convert a double to a string without notation, and tried this:
Am trying to convert my string value(the value is millisecond value) from seconds. Here
I am trying to convert string to double. But i am getting the number

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.