Search code examples
cdouble

How do I get DOUBLE_MAX?


AFAIK, C supports just a few data types:

int, float, double, char, void enum.

I need to store a number that could reach into the high 10 digits. Since I'm getting a low 10 digit # from

INT_MAX

, I suppose I need a double.

<limits.h> doesn't have a DOUBLE_MAX. I found a DBL_MAX on the internet that said this is LEGACY and also appears to be C++. Is double what I need? Why is there no DOUBLE_MAX?


Solution

  • DBL_MAX is defined in <float.h>. Its availability in <limits.h> on unix is what is marked as "(LEGACY)".

    (linking to the unix standard even though you have no unix tag since that's probably where you found the "LEGACY" notation, but much of what is shown there for float.h is also in the C standard back to C89)