Search code examples
cgcccompiler-constructioncompilationconditional-compilation

how to detect if long double is of extended precision or not at compile time


On few systems double is same as long double. How can I detect if long double is of extended precision than double at compile time and use it to conditional compile.

I see there are predefined macros present in libgcc SIZEOF_DOUBLE and SIZEOF_LONG_DOUBLE But there are not portable across different toolchains.

Is there C way to do this?


Solution

  • You could compare DBL_MANT_DIG and LDBL_MANT_DIG from float.h.