Possible Duplicates:
How would you set a variable to the largest number possible in C?
maximum value of int
I need to use the maximum integer value in my my code, but I don't want to explicitly write 4294967295. Is it defined somewhere?
value, which corresponds to 18,446,744,073,709,551,615 for the unsigned data type and ranges from -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 in the signed version.
Values of INT_MAX and INT_MIN may vary from compiler to compiler. Following are typical values in a compiler where integers are stored using 32 bits. Value of INT_MAX is +2147483647. Value of INT_MIN is -2147483648.
size_t size_max = -1; unsigned int uint_max = -1; unsigned long ulong_max = -1; assign the values SIZE_MAX , UINT_MAX and ULONG_MAX to the variables respectively.
INT_MAX
(for int
) or UINT_MAX
(for unsigned int
) defined in <limits.h>
Use limits.h
:
#include <limits.h> int maximum = INT_MAX;
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