# Euphoria運算子

Euphoria 提供了一套豐富的運算子操縱變數。我們可以把所有的運算子分成以下幾組：

• 算術運算子

• 關係運算子

• 邏輯運算子

• 賦值運算子

• 其他運算子

# 算術運算子：

+ Addition - Adds values on either side of the operator A + B will give 30
- Subtraction - Subtracts right hand operand from left hand operand A - B will give -10
* Multiplication - Multiplies values on either side of the operator A * B will give 200
/ Division - Divides left hand operand by right hand operand B / A will give 2
+ Unary plus - This has no impact on the variable value. +B gives 20
- Unary minus - This creates a negative value of the given variable. -B gives -20

# 關係運算子：

Euphoria語言支援的關係運算子

= Checks if the value of two operands are equal or not, if yes then condition becomes true. (A = B) is not true.
!= Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. (A != B) is true.
> Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (A > B) is not true.
< Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. (A < B) is true.
>= Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (A >= B) is not true.
<= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (A <= B) is true.

# 邏輯運算子：

and Called Logical AND operator. If both the operands are non zero then then condition becomes true. (A and B) is false.
or Called Logical OR Operator. If any of the two operands are non zero then then condition becomes true. (A or B) is true.
xor Called Logical XOR Operator. Condition is true if one of them is true, if both operands are true or false then condition becomes false. (A xor B) is true.
not Called Logical NOT Operator which negates the result. Using this operator, true becomes false and false becomes true not(B) is true.

# 賦值運算子：

= Simple assignment operator, Assigns values from right side operands to left side operand C = A + B will assigne value of A + B into C
+= Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand C += A is equivalent to C = C + A
-= Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand C -= A is equivalent to C = C - A
*= Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand C *= A is equivalent to C = C * A
/= Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand C /= A is equivalent to C = C / A
&= Concatenation operator C &= {2} is same as C = {C} & {2}

# 其他運算子

## '&' 操作符:

 ```#!/home/euphoria-4.0b2/bin/eui sequence a, b, c a = {1, 2, 3} b = {4} c = {1, 2, 3} & {4} printf(1, "Value of c[1] %d\n", c[1] ) printf(1, "Value of c[2] %d\n", c[2] ) printf(1, "Value of c[3] %d\n", c[3] ) printf(1, "Value of c[4] %d\n", c[4] ) ```

 ```Value of c[1] 1 Value of c[2] 2 Value of c[3] 3 Value of c[4] 4 ```

# Euphoria運算子的優先順序：

Postfix  function/type calls
Unary  + - ! not Right to left
Multiplicative   * /  Left to right
Additive   + -  Left to right
Concatenation   &   Left to right
Relational   > >= < <=   Left to right
Equality   = !=  Left to right
Logical AND  and  Left to right
Logical OR  or  Left to right
Logical XOR  xor  Left to right
Comma  Left to right