Process Data
I. Classification
Basic Type + Composite Type
Basic types include integer and floating point
Composite types include: structure (struct)
Integer Classification
Integer: Char short int long and unsigned
Float: Float double Long double
Boolean: Boole is sometimes an integer.
Ii. Integer explanation
1. Expression
Short = short int
Long = long int
2. Function usage
Sizeof () // Length byte of the returned type
Sizeof variable // parentheses can be omitted
3. Use of infinite values
To obtain the extreme values of each type. You can add
# Include "limits. H"
Int_max, int_min // represents the maximum and minimum integer values, respectively.
4. Differences between the number of unsigned characters and the number of signed characters
-128-127 0-255 short type; the highest bit of the unsigned number can be used as a value
5. Extreme Value addition and subtraction:
1> signed number: int max = int_max;
Unsigned number: Unsigned int un_max = int_max;
Max ++
Un_max ++
Max =-2 ^ 31
Un_max = 2 ^ 32 + 1
2> signed number: Short Sam = 0;
Unsigned number: Unsigned short un_sam = 0;
Sam --;
Un_sam --;
Sam =-1;
Un_sam = 255;
6, long; unsigned long: at least 64-bit
7. optimization considerations: If there are no large integers, use short (if possible)
Char can also
8, int A = 42; // decimal
Int B = 042; // hex
Int C = 0x42; // hexadecimal octal
Cout <"A =" <A <Endl; // output in decimal format
Cout <"B =" <B <Endl; // output in octal format
Cout Cout <"c =" <C <Endl; // hexadecimal output
Cout <Oct;
9. namespace
If cout is used like this
STD: cout <
STD: Endl
STD: Hex
STD: Oct
The preceding keywords (cout, Endl, Hex, Oct; such as int cout;) can be used as variable names.
STD: cout. Put ('D'); // output function
10, const read-only
Const int;
A = 9;
// This is incorrect. After definition, the value cannot be changed.
Const is better than define
1> explicitly specify the type
2> you can use the scope to limit the range of variables defined by const to a file or function.
3. Floating Point Number
1. Float 32-bit valid digits
Double 64-bit
Long Double 80 96 128
Float can only represent the first six digits of a value
2. Forced type conversion does not change the value of the variable itself.
Int B = (INT)
It does not change the value of A. It only changes the value of B.