Table 2.1: Data Types, Sizes, and Ranges Type Size (bits) Range Char or signed char
8
–128 to 127
Unsigned char
8
0 to 255
Int or signed int
16
–32768 to 32767
Unsigned int
16
0 to 65535
Short int or signed short int
8
–128 to 127
Unsigned short int
8
0 to 255
Long int or signed long int
32
–2147483648 to 2147483647
Unsigned long int
32
0 to 4294967295
Float
32
3.4 e-38 to 3.4 e+38
Double
64
1.7 e-308 to 1.7e+308
Long double
80
3.4 e-4932 to 3.4 e+4932
Note that short, long, signed, and unsigned are modifiers. These modifiers define the amount of
storage allocated to the variable. Also remember that as per ANSI
rules:
short int <= int <= long int
float <= double <= long double This means that a ‘short int’ should assign less than or the same amount of storage as an ‘int’ and the ‘int’ should require the same or fewer bytes than a ‘long int’. It is possible to find out how much storage is allocated to a data type by using the
sizeof operator .
These ranges are defined in the
limits.h header file.
Variables A variable is a named area of storage that can hold a single value (numeric or character). Every