Arithmetic operators There are two assignment operators for use with arithmetic expressions: = equals <- jam transfer Where the = operator is used, the expression on the right-hand side is evaluated and the value obtained is assigned to the destination indicated by the left-hand side, provided that the lengths and types are compatible. A fault occurs if an attempt is made to assign too large a value to a variable using this operator. Where the <- is used, only as many bits as will fit the location designated by the left hand side are assigned, starting with the least significant bits. In general the arithmetic assignment instruction assigns the result of evaluating an arithmetic expression to a variable. Only the result of an integer expression may be assigned to an integer variable, but the result of an integer or real expression may be assigned to a real variable. The following operators may be applied to real and integer variables in arithmetic expressions: _______________________________________ | | | + addition | | - subtraction | | * multiplication | | / real division | | // integer division | | \ real exponentiation | | (e.g. Y\3 = Y cubed) | | \\ integer exponentiation | |_______________________________________| The established order of precedence for the arithmetic operators is given in the following table, starting with the highest. Operators on the same horizontal line of the table have equal precedence. _________________________ | | | \ \\ | | * / // | | * - | |_________________________| Parentheses may be used to override the natural order of evaluation of an expression or to remove ambiguity. Where operators are of equal precedence, left-hand precedence pertains as in normal mathematical usage. Examples: A-B+C is equivalent to (A-B)+C A-(B+C) (A)-(B+C) A/B*C (A/B)*C A/(B*C) (A)/(B*C) A**B*C (A**B)*C A**(B*C) (A)**(B*C) The one exception to the left-hand precedence rule is that consecutive exponentiations are evaluated from right to left; thus A**B**C is evaluated as A**(B**C), not as (A**B)**C.