Here, for beginners to the C language of the small partners to introduce several basic operators. Hope that everyone's study has helped! 1. Arithmetic operator "+ (plus)", "-(minus)", "* (multiply)", "/(except)", "% (take-up)", which focuses on "%" to take the remainder operation, simply lift
instance, 12%5=2, however, be aware that both sides of a symbol must be shaped data.
2. Shift operator
<< (shift left) ">> (Shift right)", the shift is for 2 decimal digits. The right shift is divided into two cases: arithmetic right shift and logical right SHIFT, arithmetic right shift
Simple generalization: Left fill sign bit, right shift. And the logical right shift is: left 0, right shift. Take 1 as an example to illustrate:
Arithmetic shift
, Logical shift
While the left shift is relatively simple, there is only one case, right 0, left shift.
3. Bitwise operators
"& (Bitwise AND)" "| (bitwise OR)" "^ Bitwise XOR", for binary number operations, as follows:
3|5=7
4. Assignment Operator "="
To put it briefly, for example, a+=10, that is, A=A+10, both express the same meaning, obviously the former is more concise, we recommend that we use the former in the subsequent programming.
5. Single-Mesh operator (one of the required variables for the operation)
“! (non) "& (Address)" "sizeof" and so on. Here is a brief introduction to sizeof, commonly used to solve array lengths, such as sizeof (a)
/sizeof (A[0]), but be aware that sizeof is an operator, not a function. In addition, in a nutshell, sizeof is calculated during compilation, and the runtime does not
It's going to be an operation.
6. Relational operators
"&& (with)" "| | (or) "and so on, where the bitwise operators are distinguished, and the relational operators represent logical operational relationships, such as
0&& (a+10) |26-14, for this equation, see there is a && behind 0, there is no need to look down, because in the computer, this time the operation has stopped, the result
For 0, the same, 1| | (A+10) &&26-14 is 1.
In this, simple for you to introduce the C language operator, I hope you read well, there will be a harvest of Europe!!!
C language operator