运行 Xcode 11.3
为什么 pi 的有效成分等于 pi/2?
print(CGFloat.pi.significand == CGFloat.pi/2). // true
我期望有效值等于尾数。我错过了什么吗?
最佳答案
我们声明significand
如下。
let magnitude = x.significand * F.radix ** x.exponent
我假设pi = 3.14
.
所以pi = 1.57 * 2 <sup>1</sup>
哪里1.57
是significand
.
如果我们将两边除以 2,您将得到 pi/2 = 1.57
.
换句话说pi/2 = pi.significand
。 (这是一种特殊情况)。
The significand is frequently also called the mantissa, but significand is the preferred terminology in the IEEE 754 specification, to allay confusion with the use of mantissa for the fractional part of a logarithm.
更新
正如 @Ptit 所提到的,2 到 4 之间的所有数字都满足参数 number/2 = number.significand
.
关于swift - 为什么 Swift 报告 CGFloat.pi.significand 恰好是 pi/2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71686732/