Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C: Convert the entire double value to string without losing data

I have the following double value: 0.000900137869045636 which I would like to convert to a NSString.

I've tried the following code, but no matter what, it rounds the value to this: 0.000900138

[NSString stringWithFormat:@"%.20lf", [currentLocation coordinate].latitude];

What should I do to keep the double number as it is?

Thank you.

like image 285
thedp Avatar asked May 10 '13 17:05

thedp


1 Answers

Create an NSNumber using

NSNumber *myDoubleNumber = [NSNumber numberWithDouble:myDouble];

Then call

[myDoubleNumber stringValue];

like image 79
m177312 Avatar answered Sep 16 '22 15:09

m177312