Basic data type 1 data type category
Integer: short integer, integer, long integer
Character type: character
Floating-point type: Float and double represent six basic data types in C language.
2. Introduction of various data types
2. 1 integer
Shaping includes short integer, shaping and long integer.
2. 1. 1 short integer
Short a =1;
2. 1.2 integer
Generally, it accounts for 4 bytes (32 bits), with the highest bit representing a symbol, 0 representing a positive number and 1 representing a negative number. The range of values is-2147483648 ~ 2147483647, and the order of storage in memory is first high and then low, for example, 0x 12345678.
Address: 0x0012f780x0012f790x0012ff7a0x0012ff7b.
Data: 78 56 34 12
Definition: use int keyword, for example:
int a = 6;
2. 1.3 long shaping
Length a =10;
2.2 floating-point type
Floating-point type includes single precision type and double precision type.
2.2. 1 single precision type
Floating-point type, also called real type, also called single precision. Usually 4 bytes (32 bits),
Floating a = 4.5
Address: 0x0012f780x0012f790x0012ff7a0x0012ff7b.
Data: 00 00 90 40
Double precision type
Generally 8 bytes (64 bits).
Double? a = 4.5
Address: 0x0012f780x0012f790x0012ff7a0x012ff7b0x012ff7c0x012ff7d0x012ff7e.
Data: 00 00 00 00 00 12 40
2.3 Character types
In various systems, the character type accounts for one byte (8 bits). Defined as follows:
char c = ' a
You can also use ASCII codes corresponding to characters to assign values, as shown below:
char c = 97
Binocular operator of conditional expression b? X:y, calculate condition b first, and then judge. If the value of b is true, calculate the value of x, and the operation result is the value of x; Otherwise, calculate the value of y, and the result is the value of y. Conditional expressions will never evaluate both x and y. Conditional operators are right-associative, that is, they are calculated in groups from right to left. For example, a? B: C? D:e will press a? B: (C? D:e) implementation.