The C++ programming language has a wide variety of data types. In this article, you are going to get an overview of how these data types are classified.
A data type is a computer representation of identifiers such as variables or constants. The C++ data types are divided into 3 categories.
- Builtin types
- User-defined types
The C++ language supports all the primitive data types like C language. The range of each of the basic data types can be changed using modifiers. A modifier changes the range of allowed values for a builtin data type.
The C++ modifiers are listed below.
The list of all the builtin data types with each modifier and their range is given in the following table.
|char||1 byte||(2^-7) to (2^7) – 1|
|unsigned char||1 byte||0 to (2^8)-1|
|signed char||1 byte||(2^-7) to (2^7) – 1|
|int||2 bytes||(2^-15) to (2^15)-1|
|unsigned int||2 bytes||0 to (2^16)-1|
|signed int||2 bytes||(2^-15) to (2^15)-1|
|short int||2 bytes||(2^-15) to (2^15)-1|
|long int||4 bytes||(2^-31) to (2^31)-1|
|signed long int||4 bytes||(2^-31) to (2^31)-1|
|unsigned long int||4 bytes||0 to (2^32)-1|
|float||4 bytes||3.4E-38 to 3.4E+38|
|double||8 bytes||1.7E-308 to 1.7E+308|
|long double||10 bytes||3.4E-4932 to 3.4E+4932|
Note: Some of the ranges is compiler dependent.