Traditional Culture Encyclopedia - Almanac inquiry - What is the specific meaning and usage of 1 1 assignment operator in C language?
What is the specific meaning and usage of 1 1 assignment operator in C language?
= is the assignment operator,/= is the assignment after division, * = is the assignment after multiplication,
% = assignment after modulo,+= assignment after addition,-= assignment after subtraction,
2. < < = assignment after left shift, variable
3.& gt& gt= is a variable >>= In the expression, the right shift operator is used to shift each binary bit of a number by several bits to the right. The number of bits moved is specified by the right operand (the right operand must be non-negative), and the lower bits moved to the right are discarded. For unsigned numbers, the high bits are supplemented with 0.
For signed numbers, some machines will fill the left blank part with sign bits (namely "arithmetic shift"), and some machines will fill the left blank part with 0 (namely "logical shift");
For unsigned numbers, when moving to the right, the upper left bit is shifted to 0; For signed values, if the original sign bit is 0 (the number is positive), the left side will also be shifted to 0.
If the sign bit was originally 1 (that is, negative number), then whether the left side is shifted to 0 or 1 depends on the computer system used, whether it is shifted to 0 or 1.
Moving into 0 is called "logical shift", that is, simple shift; Moving in 1 is called "arithmetic shift".
4.&= After bitwise AND, the variable &; = Expression, bitwise AND indicates that two data participating in the operation are bitwise AND.
If two corresponding binary bits are both 1, the resulting value of this bit is1; Otherwise, it is 0.
5.= Assignment after bitwise XOR, variable = expression, two quantities involved in the operation are XOR according to the corresponding bits, and
0^0→0,? 0^ 1→ 1,? 1^0→ 1,? 1^ 1→0
The XOR of a number and 0 remains the same, for example, A 0 = A
The XOR result of a number with itself is 0, such as a a = 0.
1 1.|= is a bitwise or post-assignment, variable | = expression, and the two quantities involved in the operation are OR-operated according to the corresponding bits, 0|0→0,? 0| 1→ 1,? 1|0→ 1,? 1| 1→ 1。
Extended data:
The function of 1. assignment expression is to calculate the value of the expression and give it to the variable on the left.
The assignment operator is right associative, so a=b=c=5 can be understood as a=(b=(c=5)).
2. Assignment statements in other high-level languages are called assignment statements;
In c language,
=' is defined as an operator that constitutes an assignment expression.
3. The assignment expression can appear anywhere the expression appears.
For example, the formula x=(a=5)+(b=8) is legal. It means to give 5 to A, 8 to B, and then add A and B to give X, so X should be equal to 13.
4. Assignment statements can also be written in C language.
According to the provisions of the C language, any expression ending in a semicolon constitutes a statement.
- Previous article:Dream of Celebes Buffalo
- Next article:Authentic almanac almanac counts money.
- Related articles
- Chronological auspicious yellow calendar
- The baby born today in the solar calendar
- How to choose ecliptic auspicious day 202 1? March 20th, the eighth day of the second lunar month. How about getting engaged?
- What is the housewarming gift?
- Is the fifteenth day of the twelfth lunar month in 2022 an auspicious day for marriage?
- I dreamed that my boyfriend called himself and said it was a sign of breaking up.
- Pick a date in the Gregorian calendar in 2020.
- April 2020.1Gregorian calendar
- Ask for advice on the preparation of the site commencement ceremony.
- Monthly delivery in lunar calendar.