I just read that C99 has double_t which should be at least as wide as double. Does this imply that it gives more precision digits after the decimal place? More than the usual 15 digits for double?.
Secondly, how to use it: Is only including
#include <float.h>
enough? I read that one has to set the FLT_EVAL_METHOD to 2 for long double. How to do this? As I work with numerical methods, I would like maximum precision without using an arbitrary precision library.
Thanks a lot…
No.
double_tis at least as wide as double; i.e., it might be the same as double. Footnote 190 in the C99 standard makes the intent clear:As Michael Burr noted, you can’t set
FLT_EVAL_METHOD.If you want the widest floating-point type on any system available using only C99, use
long double. Just be aware that on some platforms it will be the same asdouble(and could even be the same asfloat).Also, if you “work with numerical methods”, you should be aware that for many (most even) numerical methods, the approximation error of the method is vastly larger than the rounding error of double precision, so there’s often no benefit to using wider types. Exceptions exist, of course. What type of numerical methods are you working on, specifically?
Edit: seriously, either (a) just use
long doubleand call it a day or (b) take a few weeks to learn about how floating-point is actually implemented on the platforms that you’re targeting, and what the actual accuracy requirements are for the algorithms that you’re implementing.