The required ranges for signed and unsigned int are identical to those for signed and unsigned short. On compilers for 8 and 16 bit processors (including Intel x86 processors executing in 16 bit mode, such as under MS-DOS), an int is usually 16 bits and has exactly the same representation as a short. On compilers for 32 bit and larger processors (including Intel x86 processors executing in 32 bit mode, such as Win32 or Linux) an int is usually 32 bits long and has exactly the same representation as a long.
A signed int can hold all the values between INT_MIN and INT_MAX inclusive. INT_MIN is required to be -32767 or less, INT_MAX must be at least 32767. Again, many 2's complement implementations will define INT_MIN to be -32768 but this is not required.
An unsigned int can hold all the values between 0 and UINT_MAX inclusive. UINT_MAX must be at least 65535. The int types must contain at least 16 bits to hold the required range of values.
A signed long can hold all the values between LONG_MIN and LONG_MAX inclusive. LONG_MIN is required to be -2147483647 or less, LONG_MAX must be at least 2147483647. Again, many 2's complement implementations will define LONG_MIN to be -2147483648 but this is not required.
An unsigned long can hold all the values between 0 and ULONG_MAX inclusive. ULONG_MAX must be at least 4294967295. The long types must contain at
least 32 bits to hold the required range of values.
and the proof is here:
Code:
#include <stdio.h>
#include <limits.h>
volatile int char_min = CHAR_MIN;
int main(void)
{
printf("\n\n\n\n\n Character Types\n");
printf("Number of bits in a character: %d\n",
CHAR_BIT);
printf("Size of character types is %d byte\n",
(int)sizeof(char));
printf("Signed char min: %d max: %d\n",
SCHAR_MIN, SCHAR_MAX);
printf("Unsigned char min: 0 max: %u\n",
(unsigned int)UCHAR_MAX);
printf("Default char is ");
if (char_min < 0)
printf("signed\n");
else if (char_min == 0)
printf("unsigned\n");
else
printf("non-standard\n");
printf("\n Short Int Types\n");
printf("Size of short int types is %d bytes\n",
(int)sizeof(short));
printf("Signed short min: %d max: %d\n",
SHRT_MIN, SHRT_MAX);
printf("Unsigned short min: 0 max: %u\n",
(unsigned int)USHRT_MAX);
printf("\n Int Types\n");
printf("Size of int types is %d bytes\n",
(int)sizeof(int));
printf("Signed int min: %d max: %d\n",
INT_MIN, INT_MAX);
printf("Unsigned int min: 0 max: %u\n",
(unsigned int)UINT_MAX);
printf("\n Long Int Types\n");
printf("Size of long int types is %d bytes\n",
(int)sizeof(long));
printf("Signed long min: %ld max: %ld\n",
LONG_MIN, LONG_MAX);
printf("Unsigned long min: 0 max: %lu\n",
ULONG_MAX);
return 0;
}