Вы находитесь на странице: 1из 2

Data Type In C++

In computer programming, information is stored in a computer memory with different data types. We must
know what is to be stored in a computer memory, whether it is a simple number, a letter or a very large number.
As we also know, computer memory is organized in bytes, and for these variables with varying information a data
type is associated. The minimum amount of memory in computer memory is a byte that can store a small amount
of data and managed easily. Every variable is declared with two entities, its type and its name. The fundamental
data types in C++ are the basic building blocks for creating other data types. There are five basic classifications
that form the foundation of the fundamental types: characters, integers, floating-point numbers, booleans, and
the void type.

1. Characters
The character type has two basic variants: one of ACSII characters and one for Unicode
characters. The char type is used to store 8 bit characters according to the specification in the ASCII table.
The wchar_t type is used to store 16 bit characters according to the Unicode specification for UTF 16. The
actual values stored in these data types are integers whose values are seldom used directly. However, due to the
legacy usage of C/C++, there are three specifications for the char type: char, signed char, and unsigned char

2. Integers
The integer type has three distinct sizes: 16 bit, 32 bit and 64 bit. You could also add in
the char type as an 8 bit variant. Each different size can store a corresponding range of integer values and each
has a signed and unsigned variant. Many of these have multiple names that can be used to specify it.

3. Floating-Point Numbers
The floating point number type has two distinct sizes: 32 bit and 64 bit. The 32 bit variant is
specified by the name float and the 64 bit number is specified by the name double. The double has uses twice
the memory to give a range of values and greater precision. As memory in computers has grown, the float type
has fallen out of usage in numerical programming, and virtually everyone uses the double type now.

4. Booleans
The only Boolean type is the bool data type. This is used to represent the two logical
values true and false.

5. Void
There is one Void type called void, it is not really a data type at all. It is used to specify that no
type is used. Otherwise, it can be used as a pointer type to indicate that the type is unknown.

Fundamental Data Type Table


Category

Type

Range

Size *

Character

char

[-128, 127]

1 byte

signed char

[-128, 127]

1 byte

Category

Type

Range

Size *

unsigned char

[0,255]

1 byte

wchar_t

[0, 65535]

2 bytes

short

[-32768, 32767]

2 bytes

short int

[-32768, 32767]

2 bytes

signed short int

[-32768, 32767]

2 bytes

signed

[-2147483648, 2147483647]

4 bytes

signed int

[-2147483648, 2147483647]

4 bytes

int

[-2147483648, 2147483647]

4 bytes

long

[-2147483648, 2147483647]

4 bytes

long int

[-2147483648, 2147483647]

4 bytes

signed long int

[-2147483648, 2147483647]

4 bytes

long long

[-9223372036854775808,
9223372036854775807]

8 bytes

unsigned short

[0, 65535]

2 bytes

unsigned short int

[0, 65535]

2 bytes

unsigned

[0, 4294967295]

4 bytes

unsigned int

[0, 4294967295]

4 bytes

unsigned long

[0, 4294967295]

4 bytes

unsigned long int

[0, 4294967295]

4 bytes

unsigned long long

[0, 18446744073709551615]

8 bytes

float

[-3.4*10^38, 3.4*10^38]
(7 decimal place accuracy)

4 bytes

double

[-1.7*10^308, 1.7*10^308]
(15 decimal place accuracy)

8 bytes

long double

[-1.7*10^308, 1.7*10^308]
(15 decimal place accuracy)

8 bytes

Boolean

bool

{true, false}

1 byte

Void

void

Integer

Floating Point

Вам также может понравиться