Example one:
int main ()
{
unsigned char a = 0XA5;
unsigned char b = ~a >> 1+2+3;
printf ("B =%d\n", b);
}
What is the value of Q B?
Here B = 253;
The teacher said that the first shift to take the reverse, said to take the reverse is the same as the right to the back of the operation (I novice do not understand, ~ The operational level is not higher):
1010 0101 >> 6 0000 0010 Reverse 1111 1101 (253)
Small m look at the assembly code and the result is this
1010 0101 extended to 16 bits (register 16 bits)
0000 0000 1010 0101 Reverse Priority 1111 1111 0101 1010
Re-displacement of 0000 0011 1111 1101 given b to intercept the first 8 digits 1111 1101 (253)
If A is char a = 0xa5 The value of the last B is 1
According to the teacher said ~ post-op
1010 0101 >> 6 1111 1110 reverse 0000 0001 (1)
Expand by the idea of small m (implicit conversion)
1111 1111 1010 0101 First take reverse 0000 0000 0101 1010
re-displacement 0000 0000 0000 0001 (1) also 1
is not sure that that is right or is right, I hope to have a senior to mention a bit.
Example two:
int main ()
{
Char *a = "China";
Char *b = "American;
if (strlen (a)-strlen (b) > 0)
{
printf ("china\n");
}
Else
{
printf ("american\n");
}
}
The result output is China;
Here strlen returns the unsigned type, and an implicit conversion will occur so > left is always greater than or equal to 0
Small m Summary: All data is implicitly converted until the operation is started, until a conversion is made to the assignment
The symbol is converted to unsigned, and the shape is converted to floating point.
Small m is also very vegetable. If there is any mistake, I hope that the elder ancestors WA
Displacement implicit type conversion pee