2

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?

eharo2
  • 2,553
  • 1
  • 29
  • 39
  • "I expected the significant to be equivalent to the mantissa" And it *is* equivalent to the mantissa. What do you think pi's mantissa is? – Sweeper May 05 '22 at 17:10

1 Answers1

5

We declare significand as follows.

let magnitude = x.significand * F.radix ** x.exponent

I assume pi = 3.14.

So pi = 1.57 * 2 1 where 1.57 is the significand.

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,

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.

Update

As mentioned by @Ptit all numbers between 2 and 4 satisfies the argument number/2 = number.significand.

udi
  • 3,672
  • 2
  • 12
  • 33
  • 2
    To complete, all number between 2 and for have significand = number/2 because significant is between 1 and 2. – Ptit Xav Mar 31 '22 at 06:46