C Data Types

Data types refers to an extensive system for declaring variables by specifying the kind of data to be stored in the variable. The data type also enables the computer to know the amount of memory to set aside for each variable and the total amount of memory the program may require.

The C language provides many basic types, most of which are formed from one of the four basic arithmetic type specifiers in C (char, int, float and double), and optional specifiers (signed, unsigned, short, long). All available basic arithmetic types are listed below:

The actual size of integer types varies by implementation. The standard only requires size relations between the data types and minimum sizes for each data type:

The relation requirements are that the  is not smaller than , which is not smaller than  , which is not smaller than. As 's size is always the minimum supported data type, all other data types can't be smaller.

The minimum size for  is 8 bit, the minimum size for   and   is 16 bit, for   it is 32 bit and   must contain at least 64 bit.

The type  should be the integer type that the target processor is most efficient working with. This allows great flexibility: for example, all types can be 64-bit. However, several different integer width schemes (data models) are popular. This is because the data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.http://www.unix.org/version2/whatsnew/lp64_wp.html

In practice it should be noted that  is usually 8 bits in size and   is usually 16 bits in size (as are their unsigned counterparts). This holds true for platforms as diverse as 1990s SunOS 4 Unix, Microsoft MS-DOS, modern Linux, and Microchip MCC18 for embedded 8 bit PIC microcontrollers. POSIX requires  to be exactly 8 bits in size.

The actual size and behavior of floating-point types also vary by implementation. The only guarantee is that  is not smaller than , which is not smaller than. Usually, the 32-bit and 64-bit IEEE floating point-IEEE 754 binary floating-point formats are used, if supported by hardware.

Boolean type
C99 added a boolean (true/false) type which is defined in the   header. Additionally, the standard requires that macros are defined to alias the type as  as well as providing macros for   and.

Size and pointer difference types
The C language provides the separate types  and   to represent memory-related quantities. Existing types were deemed insufficient, because their size is defined according to the target processor's arithmetic capabilities, not the memory capabilities, such as available address space. Both of these types are defined in the  header (  header in C++).

is used to represent the size of any object (including arrays) in the particular implementation. It is used as the return type of the  operator. The maximum size of  is provided via , a macro constant which is defined in the   header (  header in C++). It is guaranteed to be at least 65535.

Note that  is unsigned, signed sizes can be represented by.

is used to represent the difference between pointers.

Interface to the properties of the basic types
Information about the actual properties, such as size, of the basic arithmetic types, is provided via macro constants in two headers:  header (  header in C++) defines macros for integer types and   header (  header in C++) defines macros for floating-point types. The actual values depend on the implementation.


 * Properties of integer types
 * – size of the char type in bits (at least 8 bits)
 * ,,  ,  ,  (C99) – minimum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long long
 * ,,  ,  ,  (C99) – maximum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long long
 * ,,  ,  ,  (C99) – maximum possible value of unsigned integer types: unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long
 * – minimum possible value of char
 * – maximum possible value of char
 * – maximum number of bytes in a multibyte character


 * Properties of floating-point types
 * ,,   – minimum normalized positive value of float, double, long double respectively
 * ,,   (C11) – minimum positive value of float, double, long double respectively
 * ,,   – maximum finite value of float, double, long double respectively
 * – rounding mode for floating-point operations
 * (C99) – evaluation method of expressions involving different floating-point types
 * – radix of the exponent in the floating-point types
 * ,,   – number of decimal digits that can be represented without losing precision by float, double, long double respectively
 * ,,   – Machine epsilon-difference between 1.0 and the next representable value of float, double, long double respectively
 * ,,   – number of  -base digits in the floating-point significand for types float, double, long double respectively
 * ,,   – minimum negative integer such that   raised to a power one less than that number is a normalized float, double, long double respectively
 * ,,   – minimum negative integer such that 10 raised to a power one less than that number is a normalized float, double, long double respectively
 * ,,   – maximum positive integer such that   raised to a power one more than that number is a normalized float, double, long double respectively
 * ,,   – maximum positive integer such that 10 raised to a power one more than that number is a normalized float, double, long double respectively
 * (C99) – minimum number of decimal digits such that any number of the widest supported floating-point type can be represented in decimal with a precision of  digits and read back in the original floating-point type without changing its value.   is at least 10.