Section 3.3
Programming In QuickBASIC
3.3 Arithmetic Operators
The following numeric operators allow us to process numeric data stored in variables or
stated literally in the program.
Operation
|
Symbol
|
Example
|
|
Exponentation
|
^
|
5 ^ 3
|
|
Negation
|
-
|
-3
|
|
Multiplication
|
*
|
5 * 2
|
} Equal Precedence
|
Division
|
/
|
5 / 2
|
Integer Division
|
|
5 2
|
|
Remainder on Division
|
MOD
|
5 MOD 2
|
|
Addition
|
+
|
5 + 2
|
} Equal Precedence
|
Subtraction
|
-
|
5 - 2
|
If an expression contains several operators then the operators at the top will operate
first, then the next.
Order of precedance can be altered using brackets.
Example
this_variable% = (7+2) * 2
In this situation the part 7 + 2 in given greater precedance by the surrounding brackets.
The answer to this is then multiplied by the two. This gives the answer as 18.