iPhone;将 lat,long 字符串转换为浮点数 - 或任何其他方法?

发布于 2024-10-04 12:16:51 字数 160 浏览 6 评论 0原文

你好呀 我有一个类似于“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋心╮凉 2024-10-11 12:16:51

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文