"The data type determines the size of the data storage space, expression method, data value range and operation method."
Table of contents
Basic data types
Integer data
In C language, integer data is divided into three categories: basic integer (int), short integer (short) and long integer (long).
type | type identifier | byte | Ranges |
Signed basic shaping | [signed] int | 4 | -2147483648~2147483647 |
unsigned basic shaping | unsigned int | 4 | 0~4294967295 |
signed short | [signed] short | 2 | -32768~32767 |
unsigned short | unsigned short | 2 | 0~65535 |
signed long integer | [signed] long | 4 | -2147483648~2147483647 |
unsigned long integer | unsigned long | 4 | 0~4294967295 |
Note: "[]" in the table is an optional part, and the content in "[]" can be omitted when writing.
real data
Real data is also called floating point data. In C language, execution data is divided into three types: single precision type (float), double precision type (double) and long double precision type (long double). All real data are signed data and there is no unsigned data.
type | type identifier | byte | Numeric range | decimal precision |
Single precision type | float | 4 | ~ | 7 bits |
Double type | double | 8 | ~ | 15 people |
long double | long double | 8 | ~ | 19th place |
Character data
Character data is divided into character type (char) and unsigned character type (unsigned char).
type | type identifier | byte | Ranges |
Character type | char | 1 | -128~127 |
unsigned char type | unsigned char | 1 | 0~255 |
string data
In the C language, there is no such type of string data. Generally speaking, we use character arrays (char []) to represent string data.