Last Updated:

Data Types: C++ Programming Language

C++ is a strictly typed language and has the following DATA TYPES.

const int HELLO_WORLD=50; - It is a constant, usually called in large letters.

bool =1 or true (1) or false (0) – yes or no, logic

Int a =123; 123 – Integers

float b=(3.14); 3.14 – number with a period, up to 6 characters

double c=(3.14); 3.14 – number with a period, up to 15 characters

char – one character

1 bit = (0 or 1)

1 byte = 8 bits (0 to 255 = 256 variants)

Table - C++ Data Types

Type

byte

Range of accepted values

integer (Boolean) data type

bool

1

0 / 255

integer (character) data type

char

1

0 / 255

integer data types

short int

2

-32 768 / 32 767

unsigned short int

2

0 / 65 535

int

4

-2 147 483 648 / 2 147 483 647

unsigned int

4

0 / 4 294 967 295

long int

4

-2 147 483 648 / 2 147 483 647

unsigned long int

4

0 / 4 294 967 295

floating-point data types

float

4

-2 147 483 648.0 / 2 147 483 647.0

double

8

-9 223 372 036 854 775 808 .0 / 9 223 372 036 854 775 807.0

  • bool: Boolean type. Can take one of two values true and false. The memory footprint for this type is not precisely defined.
  • char: Represents a single ASCII character. It occupies 1 byte (8 bits) in memory. Can store any value from -128 to 127, or from 0 to 255
  • signed char: Represents a single character. It occupies 1 byte (8 bits) in memory. Can store any value from -128 to 127
  • unsigned char: Represents a single character. It occupies 1 byte (8 bits) in memory. Can store any value from 0 to 255
  • wchar_t: Represents an extended character. On Windows, it occupies 2 bytes (16 bits) in memory, on Linux - 4 bytes (32 bits). Can store any value in the range from 0 to 65,535 (with 2 bytes) or from 0 to 4,294,967,295 (for 4 bytes)
  • char16_t: Represents a single Unicode character. It occupies 2 bytes (16 bits) in memory. Can store any value from the range from 0 to 65 535
  • char32_t: Represents a single Unicode character. It occupies 4 bytes (32 bits) in memory. Can store any value from 0 to 4 294 967 295
  • short: Represents an integer between –32768 and 32767. It occupies 2 bytes (16 bits) in memory. This type also has synonyms short int, signed short int, signed short.
  • bool: Boolean type. Can take one of two values true and false. The memory footprint for this type is not precisely defined.
  • char: Represents a single ASCII character. It occupies 1 byte (8 bits) in memory. Can store any value from -128 to 127, or from 0 to 255
  • signed char: Represents a single character. It occupies 1 byte (8 bits) in memory. Can store any value from -128 to 127
  • unsigned char: Represents a single character. It occupies 1 byte (8 bits) in memory. Can store any value from 0 to 255
  • wchar_t: Represents an extended character. On Windows, it occupies 2 bytes (16 bits) in memory, on Linux - 4 bytes (32 bits). Can store any value in the range from 0 to 65,535 (with 2 bytes) or from 0 to 4,294,967,295 (for 4 bytes)
  • char16_t: Represents a single Unicode character. It occupies 2 bytes (16 bits) in memory. Can store any value from the range from 0 to 65 535
  • char32_t: Represents a single Unicode character. It occupies 4 bytes (32 bits) in memory. Can store any value from 0 to 4 294 967 295
  • short: Represents an integer between –32768 and 32767. It occupies 2 bytes (16 bits) in memory.
  • This type also has synonyms short intsigned short intsigned short.
  • unsigned short: Represents an integer between 0 and 65535. It occupies 2 bytes (16 bits) in memory. This type also has a synonym unsigned short int.
  • int: Represents an integer. Depending on the processor architecture, it can be 2 bytes (16 bits) or 4 bytes (32 bits). The range of limit values, respectively, can also vary from -32768 to 32767 (at 2 bytes) or from −2,147,483,648 to 2,147,483,647 (at 4 bytes). However, in either case, the size must be greater than or equal to the size of the short type and less than or equal to the size of the long type. This type has synonyms signed int and signed.
  • unsigned int: Represents a positive integer. Depending on the architecture, the processor can be 2 bytes (16 bits) or 4 bytes (32 bits), and because of this, the range of limit values can vary: from 0 to 65535 (for 2 bytes), or from 0 to 4,294,967,295 (for 4 bytes). Unsigned can be used as a synonym for this type.
  • long: Represents an integer ranging from −2,147,483,648 to 2,147,483,647. It occupies 4 bytes (32 bits) in memory. This type also has synonyms long intsigned long int and signed long
  • unsigned long: Represents an integer between 0 and 4,294,967,295. It occupies 4 bytes (32 bits) in memory. It has the synonym unsigned long int.
  • long long: Represents an integer ranging from −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. It usually occupies 8 bytes (64 bits) in memory. It has synonyms long long intsigned long long int and signed long long.
  • unsigned long long: Represents an integer between 0 and 18,446,744,073,709,551,615. It usually occupies 8 bytes (64 bits) in memory. It has the synonym unsigned long long int.
  • float: represents the real number of ordinary precision with floating point in the range +/- 3.4E-38 to 3.4E+38. In memory takes 4 bytes (32 bits)
  • double: Represents a double-precision floating-point real number in the range +/- 1.7E-308 to 1.7E+308. In memory occupies 8 bytes (64 bits)
  • long double: Represents a double-precision real number with a floating-point of at least 8 bytes (64 bits). Depending on the size of the memory footprint, the range of allowed values may vary.
  • void: Unvalued type: Represents an integer between 0 and 65535. It occupies 2 bytes (16 bits) in memory. This type also has a synonym unsigned short int.
  • int: Represents an integer. Depending on the processor architecture, it can be 2 bytes (16 bits) or 4 bytes (32 bits). The range of limit values, respectively, can also vary from -32768 to 32767 (at 2 bytes) or from −2,147,483,648 to 2,147,483,647 (at 4 bytes). However, in either case, the size must be greater than or equal to the size of the short type and less than or equal to the size of the long type. This type has synonyms signed int and signed.
  • unsigned int: Represents a positive integer. Depending on the architecture, the processor can be 2 bytes (16 bits) or 4 bytes (32 bits), and because of this, the range of limit values can vary: from 0 to 65535 (for 2 bytes), or from 0 to 4,294,967,295 (for 4 bytes).
  • Unsigned can be used as a synonym for this type.
  • long: Represents an integer ranging from −2,147,483,648 to 2,147,483,647. It occupies 4 bytes (32 bits) in memory. This type also has synonyms long intsigned long int and signed long
  • unsigned long: Represents an integer between 0 and 4,294,967,295. It occupies 4 bytes (32 bits) in memory. It has the synonym unsigned long int.
  • long long: Represents an integer ranging from −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. It usually occupies 8 bytes (64 bits) in memory. It has synonyms long long intsigned long long int and signed long long.
  • unsigned long long: Represents an integer between 0 and 18,446,744,073,709,551,615. It usually occupies 8 bytes (64 bits) in memory. It has the synonym unsigned long long int.
  • float: represents the real number of ordinary precision with floating point in the range +/- 3.4E-38 to 3.4E+38. In memory takes 4 bytes (32 bits)
  • double: Represents a double-precision floating-point real number in the range +/- 1.7E-308 to 1.7E+308. In memory occupies 8 bytes (64 bits)
  • long double: Represents a double-precision real number with a floating-point of at least 8 bytes (64 bits). Depending on the size of the memory footprint, the range of allowed values may vary.
  • void: type without value

Convert the binary number to a decimal number in the following way:

  • Number the numbers from zero from right to left
  • Multiply each number by 2 corresponding power 1x(2 to 0 power)
  • **Any number raised to a power of 0 is 1
  • The results are added