iPhone;将 lat,long 字符串转换为浮点数 - 或任何其他方法?
你好呀 我有一个类似于“3.1600559280405984”的字符串,它是一个纬度值。当我想将其转换为浮点值,以分配给注释/坐标时,字符串的 floatValue 返回截断的 3.160056,如何在不丢失小数的情况下获得完整的浮点值? 或者还有其他方法可以将字符串分配给坐标吗?
谢谢
Hi there
i have a string something like "3.1600559280405984" which is a latitude value. When i want to convert this into a float value, to assign to an annotation/coordinate, the floatValue of the string returns truncated 3.160056, how can i get the complete float without losing the decimals?
Or is there some other way i could assign strings to coordinates?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
float
的精度比这更高。它只是以较少的小数点显示。您可以使用
printf
或 Objective-C 等效项来打印带有更多小数点的内容。请注意,由于二进制浮点问题,其中一些可能是错误精度。您可以使用 double 来提高精度。
另请注意,您的输入一开始可能具有错误的精度。
The
float
has more precision than that. It's just being displayed with fewer decimal points.You could use
printf
or an Objective-C equivalent to print it with more decimal points. Note that some of those may be false precision, due to binary floating point issues.You can use
double
for a bit more precision.Also, note that your input probably has false precision to begin with.