2.2.Data Type

Primitive Built-in Types

C++ offers the programmer a rich assortment of built-in as well as user defined data types. Following table lists down seven basic C++ data types –

Bool Char Int Float Double Void Wchar_t

The table below shows you how much of memory and how long of digit that can be stored on data type choosing.

Type Typical Bit Width Ranges Type & Description
Bool 1byte True/false Stores either value true or false.
unsigned char 1byte 0 to 255 Typically a single octet (one byte). This is an integer type.
signed char 1byte -127 to 127
Int 4bytes -2147483648 to 2147483647 The most natural size of integer for the machine.
unsigned int 4bytes 0 to 4294967295
signed int 4bytes -2147483648 to 2147483647
short int 2bytes -32768 to 32767
unsigned short int Range 0 to 65,535
signed short int Range -32768 to 32767
long int 4bytes -2,147,483,648 to 2,147,483,647
signed long int 4bytes same as long int
unsigned long int 4bytes 0 to 4,294,967,295
Float 4bytes +/- 3.4e +/- 38 (~7 digits) A double-precision floating point value.
Double 8bytes +/- 1.7e +/- 308 (~15 digits)
long double 8bytes +/- 1.7e +/- 308 (~15 digits)
wchar_t 2 or 4 bytes 1 wide character A wide character type.
Suggest Edit