An operator is a symbol which tells the interpreter to perform specific mathematical, relational or logical operation and produce final result. This section details the operators available in GPC.
 Assignment
'=' is the assignment operator. Think of this as get sets to rather than equal to. When '=' is used, the left operand gets set to the value of the right operand.
|
Operator
|
Description
|
Example
|
|
=
|
Sets the left operand to the value of the right operand
|
a = 5;
|
|
 Arithmetic
It is often necessary to perform arithmetic on two values. The following table lists the arithmetic operators available in GPC.
In the examples, assume 'a' holds a value of 10 and 'b' holds a value of 5.
|
Operator
|
Description
|
Example
|
|
+
|
Adds two operands
|
a + b will give a value of 15
|
|
-
|
Subtracts right operand from the left operand
|
a - b will give a value of 5
|
|
*
|
Multiples both operands
|
a * b will give a value of 50
|
|
/
|
Divides left operand by right operand
|
a / b will give a value of 2
|
|
%
|
Modulus, gives the remainder of an integer division
|
a % b will give a value of 0
|
Note, GPC does not support fractions so the division operator ( / ) will drop any fractions. For example, 10 / 3 = 3 as the fraction is dropped. It also does not round, so 3 / 4 = 0 and not 1.
|
 Logical
Logical operators are important in any programming language as they allow to tell the interpreter to make decisions based on certain conditions. The following table lists the logical operators within the GPC languauge.
In the examples, assume 'a' holds a value of 1 and 'b' holds a value of 0.
|
Operator
|
Description
|
Example
|
|
&&
|
AND operator, if both operators are TRUE then the condition becomes TRUE
|
(a && b) is FALSE
|
|
||
|
OR operator, if either operand is TRUE then the condition becomes TRUE
|
(a || b) is TRUE
|
|
^^
|
XOR operator, if either operand is TRUE but not both then the condition becomes TRUE
|
(a ^^ b) is TRUE
|
|
!
|
NOT operator. Reverses the logical state of an operand.
|
!b is TRUE !a is FALSE
|
|
 Relational
Relational operators produce boolean results (TRUE or FALSE) while comparing two operands. The following tables list the relational operands which are available in GPC.
In the examples, assume 'a' holds a value of 30 and 'b' holds a value of 10.
|
Operator
|
Description
|
Example
|
|
==
|
Equal to, if the left operand holds the same value as the right then the condition becomes TRUE
|
(a == b) is FALSE
|
|
!=
|
Not equal to, if the left operand does not hold the same value as the right then the condition becomes TRUE
|
(a != b) is TRUE
|
|
>
|
Greater than, if the left operand holds a value greater than the left then the condition becomes TRUE
|
(a > b) is TRUE
|
|
<
|
Less than, if the left operand holds a value less than the left then the condition becomes TRUE
|
(a < b) is FALSE
|
|
>=
|
Greater than or equal to, if the left operand holds a value which is greater than or equal to the right then the condition becomes TRUE
|
(a >= b) is TRUE
|
|
<=
|
Less than or equal to, if the left operand holds a value which is less than or equal to the right then the condition becomes TRUE
|
(a <= b) is FALSE
|
|
|