The name operator sounds mysterious, but in fact we see it a lot more often, like =
,
,/
Category.
Operators are mainly divided into
arithmetic operators
Relational operators
Logical operators
Bit operator
Assignment operator
The following is simple Learn about the following.
As the name suggests, arithmetic operators are mainly used in arithmetic, such as addition, subtraction, multiplication and division
Briefly understand the following.
Operator | ##Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
##Add | ||||||||||||||||||||||||||||||||||||
- | subtraction | |||||||||||||||||||||||||||||||||||
* | Multiply | |||||||||||||||||||||||||||||||||||
/ | Division | |||||||||||||||||||||||||||||||||||
#% | Look for remainder | |||||||||||||||||||||||||||||||||||
自add | ||||||||||||||||||||||||||||||||||||
##-- | 自decrement |
##Operators | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
##== | Check whether the two values are equal, return True if they are equal, otherwise return False | |||||||||||||||||||||||||||||||||||
Check whether the two values are not equal, return True if they are not equal, otherwise return False | ||||||||||||||||||||||||||||||||||||
Check whether the value on the left is greater than the value on the right, if so return True otherwise return False | ||||||||||||||||||||||||||||||||||||
>= | Check whether the value on the left is greater than or equal to the value on the right, if so Returns True otherwise returns False | |||||||||||||||||||||||||||||||||||
##< | Check Whether the value on the left is less than the value on the right, if so return True otherwise return False | |||||||||||||||||||||||||||||||||||
##<= | Check whether the value on the left is less than or equal to the value on the right, if so return True otherwise return False |
##Operators | describe | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
&& | Logical and operator. If both operands are True, it is True, otherwise it is False | |||||||||||||||||||||||||||||||||||
##|| | Logical or operator. If the operands on both sides have a True, it is True, otherwise it is False | |||||||||||||||||||||||||||||||||||
Logical NOT operator. False if the condition is True, True otherwise |
Operator | ##Description |
---|---|
##& | ##The two numbers involved in the operation correspond to Carry AND. (It is 1 if both are 1)|
The binary OR corresponding to each of the two numbers involved in the operation. (If one of the two bits is 1, it is 1) | |
The corresponding binary bits of the two numbers participating in the operation are exclusive or. When the two corresponding binary bits are different, the result is 1.(If the two numbers are different, it is 1) | |
<< | ##Shifting n bits to the left is multiplying by 2 raised to the nth power. "a< |
##>> | Shift right by n bits That's divided by 2 to the nth power. "a>>b" shifts all binary bits of a to the right by b bits. |
Operator | ##Description |
---|---|
= | Simple assignment operator, converts an expression Assign the value of the formula to an lvalue |
= | Assign the value after addition |
##-= | After subtracting, assign the value |
## Multiply and then assign value | |
/= | ##Divide and then assign the value |
%= | ##Find the remainder and then assign the value |
<<= | Assign value after left shift |
Assign value after right shift | |
##Assignment after bitwise AND | |
= | Assignment after bitwise OR |
##^= | Assignment after bitwise XOR |
The above is the detailed content of An article to help you understand the basics of Go language operators and process control. For more information, please follow other related articles on the PHP Chinese website!