Basic data types

From Tux
Revision as of 22:30, 20 January 2018 by Williams (talk | contribs)
Jump to: navigation, search

C++ contains many data types, the basic data types (also fundamental or primitive) are those which are built into the core language. More complex data types are typically built upon the foundation of these basic data types.

The most common basic data types are int, double, char, and bool.

int

The int data type is used for representing positive and negative integers (whole numbers). Typically an int uses 4 bytes (32 bits) of storage. The first bit of an int is used for the sign (positive or negative) and the remaining 31 bits are used to encode the integer in binary. Thus, the typical range of an int is -231 to 2^31 - 1</math>. Note that the positive range is - 1 because of the representation of zero is included in the positive numbers but there is no "negative zero".

double

char

bool