1, non-Boolean variable assignment to Boolean variable: 0 is False, not 0 is true
2. Boolean variable assigned to non-Boolean variable: false is 0,true to 1
3. Floating-point numbers are assigned to integers: Only the integer portion of the floating-point number is retained, and no overflow is discussed
4, integer assigned to floating point number: The fractional part of an integer is divided into 0, the overflow situation is not discussed temporarily
5, assign a number to unsigned type, and overflow: first do the modulo operation, and then assign the value
unsigned int i;
i =-8;
Then i = 2^32-8
6. Assign a negative number to the unsigned type: first do the modulo operation, then assign the value
7, negative numbers and unsigned to do addition arithmetic operations, the first negative to the unsigned number (first modulo, then assign value), and then do the arithmetic operation
int main ()
{
unsigned int u = 10;
int i =-42;
Int J;
cout<< "U + i =" <<u+i<<endl;
cin>>j;
return 0;
}
The result is: (2^32-42) +10=4294967264
8, the value of the small unsigned number and the value of a large unsigned subtraction arithmetic operation, first do subtraction, and then the negative result into an unsigned number
int main ()
{
unsigned int u = 42;
unsigned int i = 10;
Int J;
cout<< "i-u =" <<i-u<<endl;
cin>>j;
return 0;
}
The result is: (10-42) +2^32 =4294967264
C + + type conversions