C Data Types - Basic Types

Basic Types

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

Type Explanation Type Explanation
char smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned depending on implementation signed char same as char, but guaranteed to be signed.
unsigned char same as char, but guaranteed to be unsigned.
short
short int
signed short
signed short int
short signed integer type. At least 16 bits in size. unsigned short
unsigned short int
same as short, but unsigned.
int
signed int
basic signed integer type. At least 16 bits in size. unsigned
unsigned int
same as int, but unsigned.
long
long int
signed long
signed long int
long signed integer type. At least 32 bits in size. unsigned long
unsigned long int
same as long, but unsigned.
long long
long long int
signed long long
signed long long int
long long signed integer type. At least 64 bits in size. Specified since the C99 version of the standard. unsigned long long
unsigned long long int
same as long long, but unsigned. Specified only in C99 version of the standard.
float (single precision) floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 single precision floating point format.
double double precision floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 double precision floating point format.
long double extended precision floating-point type. Actual properties unspecified. Unlike types float and double, it can be either 80-bit floating point format, the non-IEEE "double-double" or IEEE 754 quadruple precision floating-point format if a higher precision format is provided, otherwise it is the same as double. See this page for details.

The actual size of integer types varies by implementation. The only guarantee is that the long long is not smaller than long, which is not smaller than int, which is not smaller than short. Also, int 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, only several different integer width schemes (data models) are popular and since data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.

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

Read more about this topic:  C Data Types

Famous quotes containing the words basic and/or types:

    There’s one basic rule you should remember about development charts that will save you countless hours of worry.... The fact that a child passes through a particular developmental stage is always more important than the age of that child when he or she does it. In the long run, it really doesn’t matter whether you learn to walk at ten months or fifteen months—as long as you learn how to walk.
    Lawrence Kutner (20th century)

    The rank and file have let their servants become their masters and dictators.... Provision should be made in all union constitutions for the recall of leaders. Big salaries should not be paid. Career hunters should be driven out, as well as leaders who use labor for political ends. These types are menaces to the advancement of labor.
    Mother Jones (1830–1930)