Purpose
Beyond merely shuffling information from one place to another, organization is accomplished by combining and operating on items to produce new items.
This section describes common infix operators.
Operators for simple types
There are a variety of different infix operators. Infix means that
expressions are written in a ?conventional math? format with the
operator in between the two parameters it relates to. For example to
add two variables and assign them to a third is done with:
Sum:=Operand1+Operand2;
Spaces are not required between the operator and the operands. A
frequently encountered need is to increment a variable by one. In
pascal this is usually done with the command:
NumberOfPartsCompleted:=NumberOfPartsCompleted+1;
In this particular case the compiler recognizes that the destination of this
operation and the source are the same and that the amount being added is one.
This becomes a native increment instruction for the processor.
Infix Operations include
+ {Addition operator}
- {Subtraction operator}
* {Multiplication operator}
div {integer division}
/ {floating point division, i.e. fractional}
and {logical and operator for booleans, bitwise and for ordinals}
or {logical or operator for booleans, bitwise or for ordinals}
xor {logical exclusive or operator for booleans, bitwise exclusive or for ordinals}
Operations may be grouped with parenthesis to explicitly control
precedence, i.e.
Answer:=(A+(B*C));
would be a different answer from:
Answer:=(A+B)*C);
Multiplication and division have
higher precedence than addition and subtraction however
being explicit is often much clearer.