The standard header file float.h contains definitions of constants related to floating point arithmetic, such as the minimum, maximum and precision of different floating-point data types. For some time now, float.h has not contained literal numbers, but definitions in terms of other constants starting with "__" that seem to be hard-coded into the C preprocessor. This is fine for programs, but does not allow viewing the constants.
The obvious way to find out these constants is to write a small C program printing them out, but I soon got tired of this. Eventually I wrote a shell script that feeds a here document containing the constants into the C preprocessor and prints out the result. The script prints out a brief description for each constant, by feeding corresponding strings into cpp and stripping the quotes with sed afterwards. For completeness, it also prints the integer data type limits from limits.h in the same way. I am posting this here in the hope that it will be useful to other folks too.
Its usage is simply:
The script uses the environment variable CPP for the path to the C preprocessor, if available. So you can also use it to print the machine limits of a different architecture if you have a cross-compilation toolchain installed, for example:
Just don't forget to also set your include path for cross-compiling, in case the header file differs.
Officer, I had to drive home - I was way too drunk to teleport!