previous contents index next
(..Operators..) Contents Index (..Operators)

2.7.4 Arithmetical Operators (AddOp, MulOp)

Of course, SCARLET knows the four basic operators of arithmetic.

MulOp:
* Multiplication
% Modulus
/ Division

AddOp:
+ Addition
- Subtraction

Their use does in no way differ from what we would expect; as usually they operate on the set of integer expressions and have integer expressions as results, too. Furthermore it should not be surprising that divisions by zero are not allowed.
Please notice that all operations happen on a subset of ZZ; therefore, the normal division has to be replaced with the integer division /, which returns the integer part of the division, and the modulus %, which returns the remainder.


Example 12:

7 % 3          leadsto  1

7 / 3          leadsto  2

7 % 3 + 7 / 3  leadsto  3  

 

+ and - have a second meaning as unary operators: in this case they are used as signs and stand right in front of the operand.


 

On top of everything, + works as a concatenation operator, if it is applied to two string expressions.

StringExpression1 + StringExpression2

denotes the string expression that will emerge, if StringExpression2 is attached to StringExpression1. Certainly the maximum string length of 255 characters must not be exceeded in process.


Example 13:

"thousand "+ "five"  leadsto  "thousand five"

previous contents index next
(..Operators..) Contents Index (..Operators)