#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 do for float and double? how min calculated this variable? sorry bad english
Floating-point numbers suffer from a loss of precision when represented with a fixed number of bits (e.g., 32-bit or 64-bit). This is because there is an infinite amount of real numbers, even within a small range like 0.0 to 0.1.
A floating point number does not "reserve space" for the digits after the decimal point - it has a limited number of digits (23 binary) and remembers what power of two to multiply it by.
The limits for floating point types are defined in float.h not limits.h
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With