nanoprintf icon indicating copy to clipboard operation
nanoprintf copied to clipboard

Promote %f to long double option

Open ZERICO2005 opened this issue 7 months ago • 1 comments

Currently, nanoprintf casts long double or %Lf arguments to double. It would be good to have an option so float and double could be promoted to long double instead. Especially where long double is 64 bits or less on a given platform.

ZERICO2005 avatar May 14 '25 17:05 ZERICO2005

This may be tricky to test. Since promoting to long double only works if (LDBL_MANT_DIG <= 53) && (LDBL_MAX_EXP <= 1024), which might require additional #ifdef's and conditional compilation.

It could go under the NANOPRINTF_USE_* defines as NANOPRINT_USE_LONG_DOUBLE_PROMOTION like I've done here. Although it might be better to have it implemented similarly to NANOPRINTF_CONVERSION_FLOAT_TYPE as NANOPRINTF_PROMOTE_TO_LONG_DOUBLE 0/1 like I've done here.

ZERICO2005 avatar May 14 '25 19:05 ZERICO2005