02 operators

Go operators are built into the language:

    算术运算符
    关系运算符
    逻辑运算符
    位运算符
    赋值运算符

Arithmetic operators 1.1

Operators description
+ Adding
- Subtraction
* Multiplied
/ Divided
% Remainder

Note: ++ (increment) and - (decrement) Go is a single statement in the language, not the operator.

1.2. Relational operators

Operators description
== Check the two values ​​are equal, equal returns True if otherwise False.
!= Check the two values ​​are not equal, not equal returns True if otherwise False.
> Check the left value is greater than the right value, it returns True if it is otherwise False.
>= Check the left value is greater than or equal to the right value, it returns True if it is otherwise False.
< Check the left value is less than the right value, returns True if it is otherwise False.
<= Check the left value is less than or equal to the right value, returns True if it is otherwise False.

1.3. Logical Operators

Operators description
&& Logical AND operator. If both sides of the operands are True, compared to True, otherwise False.
ll Logical OR operator. If the number of operations on both sides of a True, compared to True, otherwise False.
! Logical NOT operator. If the condition is True, it was False, otherwise True.

1.4. Bitwise operator

Bitwise operators of integer bits in the memory operation.

Operators description
& And two binary phase number corresponding to each of the participating operation. (Only two are 1 to 1)
l Two involved in computing the number corresponding to each phase, or binary. (Two have a 1 on 1)
^ Two involved in computing the number corresponding to the respective binary or different, when two dissimilar corresponding binary, the result is 1. (Two are not the same, compared with 1)
<< N-bit left shift is multiplied by 2 ^ n. "A << b" is the whole of a respective binary b-bit left shift, the high discard, low 0s.
>> Right by n bits is divided by 2 ^ n. "A >> b" is a whole to the right of each binary bit b.

1.5. Assignment operator

Operators description
= Simple assignment operator, the value of the expression of a value assigned to a left
+= Added together before assignment
-= After subtraction assignment
*= By multiplying assignment
/= Division after assignment
%= Remainder after assignment
<<= Left after the assignment
>>= Right after the assignment
&= Bitwise and after the assignment
l= After pressing position or assignment
^= 按位异或后赋值

Guess you like

Origin www.cnblogs.com/kaid/p/12381562.html