sizeof(long double) differs in Intel vs. ARM64 (ARM64 long doubles are just doubles). How to get extended precision in Apple Silicon?

sizeof(long double) is 16 (aka 128 bits) in Intel Macs for alignment purposes but is actually 80 bit precision according to their documentation. In Apple Silicon, long doubles are just doubles. Anybody know how I can get 80 bit precision or better in my ARM64 slice?

Replies

The 80-bit floating point format you’re using is very Intel-specific. It’s not supported on Apple Silicon. AFAICT there’s no built-in support for floating-point numbers larger than Float64. If you absolutely need that, you’ll have to look for a third-party library that does this.

Keep in mind that this will be implemented in software and thus there’ll be a significant performance impact.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
  • Quinn, thank you for your response, it has clarified an issue I have been pondering.

    Out of curiosity, a few years ago, I wrote a Random Number Generator based on original work by MIT, Boston, in the mid 80s, project URN. It is simple, cute, and fast, with the period of the generator is expected to be around 10^171. And uniformity looks really really good, based on NIST Test Suite done years ago.

    I came back to it today, wondering if MacOS Big Sur had implemented 128bit functionality in Xcode C++, and maybe I could deploy it in my Random Number Generator.

    I found  Size of Long Double: 16 or 128bit, and as Size of Double 8 or 64bit, was so encouraged... But testing showed Long Double appeared to be the same as Double. It was exciting to find 2^216 gave me an exact result: 105312291668557186697918027683670432318895095400549111254310977536 to the very last of the 78 digits. As did 2^-49: 1.7763568394002504646778106689453125e-15 to 36 digits but digging around, discovered it turns out to be a quirk of an exact binary number, versus decimal approximation, which is limited of 19 digits. (I wonder why the 2^216 calculation did not result in an overflow?)

    So thank you, once again for your excplation... Since could not find how to deploy Float80 in Xcode C++, I have now happily satisfied my curiosity, and closed out the project.

  • Agh, sorry, the line feeds did not stick...

Add a Comment

Agh, sorry, the line feeds did not stick

Indeed. If you put your text into an answer (the Your Answer field) rather than a comment, it’ll be much more readable.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"