I. Data Types
The data type is a way to express data in the specified form, and the space occupied by different data types is also different.
For ease of learning, I specially sorted out the data type classification structure of C language, such:
You should also understand the following data types:
1. The Int type of integer data can be short, long, or long. The Int type can be omitted. The default Integer Data constant is int.
2. Integer Data int can be 10 (default), 16 (starting with 0x), and 8 (starting with 0.
For example:
8 indicates a decimal integer of 8.
08 indicates an octal integer of 8
0x8 indicates a hexadecimal integer 8.
3. for integer and floating point data, you can add signed and unsigned modifiers to indicate whether the data is signed. The data is signed by default. If you do not want to carry the symbol, use unsigned modifier.
4. floating point data can contain decimal places (. 6 indicates that it can contain six decimal places). By default, floating point data is treated as double.
5. Integer and floating point constants can contain type descriptions (the type description is case insensitive ):
For example:
8l, long type
8ll, long type
8llu or 8ull indicates the unsigned long type.
56.0 indicates Double Type
56.0f or 56. F indicates float type, but 56f is incorrect.
56.0l indicates the Long Double Type
6. Summary of data prefixes of Integer constants: 0 and 0x, which indicate octal and hexadecimal respectively.
7. Summary of data suffixes of Integer constants: l, ll; U.
8. Summary of floating point constant data suffixes: F, L, and U.
9. Scientific notation can be used to represent floating point data.
For example:
13.1e9 represents the population of China, multiplied by 13.1 by the 9 power of 10.
Ii. bytes occupied by basic data
Different computing systems also have different representation of the length of basic data types. The following is a summary of the length of each data type in a 32-bit computer system:
Char 1 byte
Short 2 bytes
Int 4 bytes
Long 4 bytes
Long long 8 bytes
Float 4 bytes
Double 5 bytes
Long Double 12 bytes
If you want to obtain the length of the data of a specific system, you can use the sizeof operator, such as sizeof (INT );
3. Constants
When it comes to data types, they are naturally associated with variables and constants.
A variable represents the amount that a value can change. The variable must be defined before use.
A constant is a constant that can be directly used without changing the value during program execution.
Constants can be divided:
1. Direct constants: 10, 23.0f, and 234ll.
2. Symbolic constants: There are two types of symbolic constants: macro definition and const statement definition.
For example:
# Define PI 3.14
Const float Pi = 3.14;