C++ Data Type Classification

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.

Advertisements
  • Builtin types
  • User-defined types
  • Derived-types
Data Types Classification
Figure 1 – Data Types Classification

Modifiers

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 built-in data type.

Advertisements

The C++ modifiers are listed below.

  • signed
  • unsigned
  • short
  • long

The list of all the builtin data types with each modifier and their range is given in the following table.

Data TypeSize Range
char1 byte(2^-7) \hspace{5px} to \hspace{5px}(2^7) - 1
unsigned char1 byte0  \hspace{5px} to \hspace{5px} (2^8)-1
signed char1 byte(2^-7)  \hspace{5px} to \hspace{5px} (2^7) - 1
int2 bytes(2^-15)  \hspace{5px} to \hspace{5px} (2^15)-1
unsigned int2 bytes0  \hspace{5px} to \hspace{5px} (2^16)-1
signed int2 bytes(2^-15)  \hspace{5px} to \hspace{5px} (2^15)-1
short int2 bytes(2^-15)  \hspace{5px} to \hspace{5px} (2^15)-1
long int4 bytes(2^-31)  \hspace{5px} to \hspace{5px} (2^31)-1
signed long int4 bytes(2^-31)  \hspace{5px} to \hspace{5px} (2^31)-1
unsigned long int4 bytes0  \hspace{5px} to \hspace{5px} (2^32)-1
float4 bytes3.4E-38  \hspace{5px} to \hspace{5px} 3.4E+38
double8 bytes1.7E-308  \hspace{5px} to \hspace{5px} 1.7E+308
long double10 bytes3.4E-4932  \hspace{5px} to \hspace{5px} 3.4E+4932
Table 1 – C++ Data Type Classification

Note: Some of the ranges is compiler dependent.

Advertisements

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.