From Newsgroup: comp.lang.c
On 01/10/2026 03:33, bart wrote:
On 01/10/2026 01:47, Lawrence DrCOOliveiro wrote:
A couple of things stand out immediately: one is that the rCLlong
doublerCY type doesnrCOt seem to make use of all the 128 bits it occupies. >> I was expecting a mantissa length closer to 100 bits, but itrCOs nowhere
near that.
Probably it uses Intel's 80-bit x87 FPU format. That uses a 64-bit
mantissa (with explicit top bit).
Yes, that's the default for "long double" in the standard x86-64 ABI.
On 32-bit x86, these 10-byte doubles were often stored in 12-byte
(96-bit) containers for better alignment, but I don't know the ABI
standards here.
On 64-bit x86, for better alignment they are stored in 16-byte
containers. The rest of the space will be padding.
gcc supports "-mlong-double-64", "-mlong-double-80" and
"-mlong-double-128" flags. With 64-bit long doubles, they are
effectively the same as doubles, and thus faster. 80-bit long doubles
are the standard, while 128-bit long doubles give quad-precision range
and precision, but must be handled in software through the gcc-provided "libquad" library functions.
You can also use the _Float128 or _Float128x types, which are optional
types in the C standards (along with 16, 32 and 64-bit versions). The
"x" types are for calculations and might be bigger than their name
applies, while the non-x types are "interchange" types that have the
same format on all systems.
10 bytes would be an odd size though, so it's rounded up to 16 bytes in
the implementation.
I don't know if current hardware would directly support a full 128 bits,
or it needs to be emulated.
IBM's POWER processors are, I think, the only cpus with hardware quad-precision floating point that are realistic. RISC-V has the Q
extensions specified, but I do not believe anyone actually makes RISC-V
cores with quad floating point.
However, float limits (in float.h) should give a clue as to the actual
range and precision.
Yes.
You can also just write some code in godbolt.org, and see if it calls
library functions like "__multf3" instead of generating hardware
instructions, as you play around with the compiler flags.
--- Synchronet 3.22a-Linux NewsLink 1.2