Arithmetic Operator
- +: Addition-the values on both sides of the addition operation, for example a+b=5
- -: Subtraction-the left operand subtracts the right operand, for example ab=3
- ×: Multiplication-the values on both sides of the multiplication operator, for example a*b=20
- /: Division-divide the left operand by the right operand, for example a/b=5
- %: Take the remainder-the left operand divided by the right operand, for example a%d=1
- ++: Increment-the operand increases by 1, such as a++, ++a
- –: decrement-the operand is reduced by 1, such as a--, --a
The following example operation
results are
Relational operator
-
==: Check if the values of the two operands are equal, for example (a==a) is true
-
! =: Check if the values of the two operands are not equal, for example (a!=b) is true
-
> Check whether the value of the left operand is greater than the value of the right operand, for example (a>b) is true
-
<: Check whether the value of the left operand is less than the value of the right operand, for example (a<b) is false
-
<=: Check whether the value of the left operand is less than or equal to the value of the right operand, for example (a<=b) is false
-
>=: Check whether the value of the left operand is greater than or equal to the value of the right operand, for example (a>=b) is true
The following example operation
results are
Short-circuit logic operator
- &: and-return true before and after it is correct, and return false if one of them is wrong
- |: Or-there is a correct return true before and after, and false returns are both false
- ! : Non-return true if followed by an error, false if it is correct
- &&: Similar to &, but not executed directly after the previous error (usually it is not possible to write a/0, but as long as the previous error is run, the latter will not be executed directly (short circuit))
- ||: Similar to |, but the front is correct and the back is not executed directly
(similar to &&)
The following example operation
The result is