Running Xcode 11.3
Why is the significant component of pi equal to pi/2?
print(CGFloat.pi.significand == CGFloat.pi/2). // true
I expected the significant to be equivalent to the mantissa.. Did I miss something?
Running Xcode 11.3
Why is the significant component of pi equal to pi/2?
print(CGFloat.pi.significand == CGFloat.pi/2). // true
I expected the significant to be equivalent to the mantissa.. Did I miss something?
Copyright © 2021 Jogjafile Inc.
We declare
significandas follows.let magnitude = x.significand * F.radix ** x.exponentI assume
pi = 3.14.So
pi = 1.57 * 2 1where1.57is thesignificand.If we divide both sides by 2 you will get
pi/2 = 1.57.In other words
pi/2 = pi.significand. (this is kind of a special case).According to the apple documentation,
Update
As mentioned by @Ptit all numbers between 2 and 4 satisfies the argument
number/2 = number.significand.