spec

Software for Diffraction

2.3.16.3. - Binary Operators



All binary operators have lower precedence than the unary operators. Binary operator precedence is indicated in the grammar rules that are listed 2.3.18 where higher precedence operators are listed first, and operators with the same precedence are listed on the same line. Binary operators with the same precedence are evaluated left to right.
 Operator   Name   Result (L is left operand, R is right) 

 *   Multiplication   L × R 
 /   Division   L / R 
 %   Modulus   Remainder of L / R (operands are integers). 
 +   Addition   L + R 
 -   Subtraction   L - R 
 <   Less than   1 if L < R (or 0 if not). 
 >   Greater than   1 if L > R (or 0 if not). 
 <=   Less than or equal   1 if L <= R (or 0 if not). 
 >=   Greater than or equal   1 if L >= R (or 0 if not). 
 ==   Logical equality   1 if L is equal to R (or 0 if not). 
 !=   Logical inequality   1 if L is not equal to R (or 0 if it is). 
 &&   Logical and   1 if both L and R are nonzero, otherwise 0. 
 ||   Logical or   1 if either L or R are nonzero, otherwise 0. 
 <<   Bitwise left shift   L shifted left by R bits (both integers). 
 >>   Bitwise right shift   L shifted right by R bits (both integers). 
 &   Bitwise and   "Bitwise and" of integers L and R
 ^   Bitwise exclusive or   "Bitwise exclusive or" of integers L and R
 |   Bitwise or   "Bitwise or" of integers L and R
    Concatenation   LR 

If either of L or R are strings, the relational operators <, >, <=, and >= use the lexicographic comparison provided by the C subroutine strcmp().

The concatenation operator comes into effect when expressions are combined separated only by space characters. The resulting expression is the concatenation of the string values of the constituent expressions. Concatenation is only allowed on the right side of an assignment operator, in the arguments to the print command and in the value assigned to a variable in a constant statement. Concatenation has lower precedence than the other operators. For example,
1.FOURC> print "ab" "cd"  1 2 + 3 4
abcd154 2.FOURC>