Search code examples
ctypesfloating-pointlimit

Limits for floating point types?


#include <stdio.h>
#include <limits.h>
 
int main(void){
        printf("Type                Size      Min                 Max\n----------------------------------------------------------------------\n");
        printf("%-20s%-10d%-20ld%-20ld\n", "long", sizeof(long), LONG_MIN, LONG_MAX);
        printf("%-20s%-10d%-20lu%-20lu\n", "unsigned long", sizeof(long), 0, ULONG_MAX);
        return 0;
}

where double? i.e. variable LONG_MIN be in file limits.h. in which type double?

   int i, min, max;

    for (i = 1.0; i > 0; ++i)
    {
        max = i;
    };
    min = i;
    printf ("int: min: %d max: %d \n", min, max);

How to do that for float and double? How is min calculated for this variable? sorry bad english


Solution

  • on linux, I have float.h which has FLT_MAX and DBL_MAX defined for maximum float and double values respectively. I'm not sure how "standard" that is, though...