Ios 哪个数据类型将按原样返回值(37.961498)?双盲';行不通

Ios 哪个数据类型将按原样返回值(37.961498)?双盲';行不通,ios,iphone,objective-c,mkmapview,type-conversion,Ios,Iphone,Objective C,Mkmapview,Type Conversion,哪个数据类型将按原样返回值(37.961498) 我在MapView工作。其中,目前我正在设置注释,因此我必须使用从googleAPI解析的一些lat和lng(例如:lat=“37.9615000”和lng=“60.5566000”)设置CLLocationCoordinate2DMake。我有字符串中的值,因此我将sting转换为double,然后赋值,但没有帮助。请找个人来帮我 double int1=[num1s floatValue]; double int2=[num2s

哪个数据类型将按原样返回值(37.961498)

我在MapView工作。其中,目前我正在设置注释,因此我必须使用从googleAPI解析的一些lat和lng(例如:lat=“37.9615000”和lng=“60.5566000”)设置CLLocationCoordinate2DMake。我有字符串中的值,因此我将sting转换为double,然后赋值,但没有帮助。请找个人来帮我

   double int1=[num1s floatValue];
    double int2=[num2s floatValue];
   NSLog(@" %f %f ",int1,int2);
    annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
实际值为:37.9615000,60.5566000 我在NSLog中得到的值:37.961498,60.556599

提前谢谢

我需要精确值的更多解释和原因:

我需要为中国及其lat和lan设置注释(lat=“53.5609740”; 液化天然气=“134.7728099”)

但当再次从字符串转换时,值会发生变化


当将
字符串
转换为
双值
时,应使用
双值
而不是
浮动值

double int1=[num1s doubleValue];
double int2=[num2s doubleValue];
NSLog(@" %f %f ",int1,int2);
annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
也不是很关键,但我不建议将您的双打命名为int1和int2,这可能会在某些时候引起您的混淆

double int1=[num1s floatValue];
double int2=[num2s floatValue];
NSLog(@" %0.7f %0.7f ",int1,int2);
annotation.coordinate=CLLocationCoordinate2DMake(int1, int2);
阅读更多信息

annotation.coordinate=CLLocationCoordinate2DMake([nums doubleValue], [int2 doubleValue]);

试试这个

顺便问一下,你有什么问题?为什么你需要精确的结果?来做注释。因为一分钟的值会改变注释,所以我需要精确的结果。但是你一开始就没有“精确”的结果。您的值以float开头,永远不会是“精确的”。(阅读上面的参考资料。)而NSLog是:5.356097e+01 1.347728e+02:(帮助我需要获得53.5609740 134.7728099。@SiddarthHailstorm--您可能需要更改格式以显示所有数字--
NSLog(@“%20.16f%20.16f”,int1,int2);
现在是:53.5609740000000016 134.77280989999986我需要53.5609740 134.7728099,因为一分钟的值将更改批注。另外还有一个问题,对于NSLOg来说,没问题!如何更改“annotation.coordination=CLLocationCoordinate2DMake(int1,int2);”?@SiddarthHailstorm-为什么需要更改2DMake语句?(你认为什么是可以改变的?)我不需要更改2DMake语句!请让我向您解释清楚。实际上,我正在将搜索字符串解析为google api,并在字典中获取结果。然后我将所有字典放入一个数组中。稍后,我使用for循环获取特定的字典。然后我从中获取地址值和名称值使用键的字典。现在我将名称、lat、lan存储在字符串中,我需要转换字符串以在注释中使用它。coordinate=CLLocationCoordinate2DMake(int1,int2);以便对其进行注释。您的代码返回:53.5609741210937500 134.7728118896484375我只需要53.5609740 134.7728099。谢谢。请再次检查您在打印数字时使用的格式。抱歉,伙计!现在完成了!正在打印,但如何在坐标中实现此操作?annotation.coordinate=CLLocatiOnCoordinated2DMake(int1,int2);?我将如何在代码中添加这些%0.7?您能告诉我语法吗?您可以这样做:uiLabel.text=[NSString stringWithFormat:@“%0.7f%0.7f”,annotation.coordinate.lation,annotation.coordinate.longitude];