首页 > 解决方案 > How to get the smallest possible Float in Swift

问题描述

I want to find, programmatically, and portably, the smallest Float possible.

By smallest I mean the smallest > 0 Float. Any way to achieve that ?

标签: swiftfloating-point

解决方案


查找Float我发现的文档:Float.leastNonzeroMagnitude

最小的正数。

此值比较小于或等于所有正数,但大于零。如果类型支持次正规值, leastNonzeroMagnitude则小于leastNormalMagnitude;否则他们是平等的。


推荐阅读