Search code examples
swiftlong-double

Long Double in Swift


In C, there is a type called long double, which on my machine is 16-bytes (128-bit). Is there any way to store a long double in Swift? I've tried type aliases (typedefs) of long double from an Objective-C header, but it doesn't show up in Swift. And functions returning long double (powl, sqrtl) don't show up neither.

I know there's a Float80 but that's only 80 bits, not 128 bits.


Solution

  • Unless you have a POWER processor, your 128 bit long double is actually an 80 bits extended precision number, plus 48 bit wasted.