在 swift 中比 double 更精确

More precision than double in swift

Swift 中是否有比 Double 更准确的浮点数?我知道在 C 中有 long double,但我似乎无法在 Apple 的新编程语言中找到它的等价物。

如有任何帮助,我们将不胜感激!

是的,有! Float80 正是为此,它存储 80 位 (duh),10 个字节。您可以像使用任何其他浮点类型一样使用它。请注意,Swift 中有 Float32Float64Float80,其中 Float32 只是 FloatFloat64 的类型别名是 Double

目前iOS 11+ 在 64 位平台上运行,Double 最高。

Double has a precision of at least 15 decimal digits, whereas the precision of Float can be as little as 6 decimal digits. The appropriate floating-point type to use depends on the nature and range of values you need to work with in your code. In situations where either type would be appropriate, Double is preferred.

但是在 CGFloat 中,用于存储 CGFloat 的本机类型在 32 位架构上为 Float,在 64 位架构上为 Double

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html