Consider the following C code:
#include
int main(int argc, char* argv[])
{
const long double ld = 0.12345678901234567890123456789012345L
Various C implementations of the long double may have variant range and precision. The sizeof hints to the underlying floating point notation, but does not specify it. A long double is not required to have 33 to 36 decimals. It could even have exactly the same representation as a double.
Without hard-coding the precision, but using all the available precision and not overdoing it, recommend:
const long double ld = 0.12345678901234567890123456789012345L;
printf("%.*Le\n", LDBL_DIG + 3, ld);
printf("%.*Le\n", LDBL_DIG + 3, nextafterl(ld, ld*2));
This prints out (on my eclipse intel 64-bit), of course, yours may differ.
1.234567890123456789013e-01
1.234567890123456789081e-01
[Edit]
On review, a +2 is sufficient. Better to use LDBL_DECIMAL_DIG. see Printf width specifier to maintain precision of floating-point value
printf("%.*Le\n", (LDBL_DIG + 3) - 1, ld);
printf("%.*Le\n", LDBL_DECIMAL_DIG - 1, ld);