Formula Operators

 

Objective Grid supports all the arithmetic, boolean and logical operators available in the C programming language. It does not support the C address operators or the operators that have side effects, such as ++. Objective Grid provides two operators, exponentiation (**) and percent (%), that are not available in the C language.

 

Objective Grid Formulas can contain the following operators to define relationship between values.

 

Operator Precedence Definition

ü  % 14 Unary percent

ü  ** 13 Exponentiation

ü  + 12 Unary plus

ü  - 12 Unary minus

ü  ~ 12 Bitwise complement (integer)

ü  ! 12 Logical not

ü  * 11 Multiplication

ü  / 11 Division

ü  % 11 Remainder (integer)

ü  + 10 Addition

ü  - 10 Subtraction

ü  << 9 Shift left (integer)

ü  >> 9 Shift right (integer)

ü  < 8 Less Than

ü  > 8 Greater Than

ü  <= 8 Less Than or Equal

ü  = 8 Greater Than or Equal

ü  == 7 Equal

ü  != 7 Not Equal

ü  & 6 Bitwise And, or String Concatenation

ü  ^ 5 Bitwise Exclusive-Or (integer)

ü  | 4 Bitwise Or

ü  && 3 Logical And

ü  || 2 Logical Or

ü  ?: 1 Conditional

 

In formulas with more than one operator, Objective Grid evaluates operators in the order of precedence presented above, with highest precedence first. That is, AND/OR/NOT operators are evaluated after inequality operators in a logical expression, and multiplication/division operations are performed before subtraction/addition operations in an arithmetic expression. Operators at the same precedence level are evaluated from left to right. The precedence of operators can be overridden by using parentheses to explicitly specify the order of evaluation.

 

Here are some special notes about Objective Grid operators:

 

ü  The operators marked ``(integer)"" on the table above automatically convert their operands to integers.

ü  The & operator performs double duty: as a bit-wise ``and"" if the operands are numbers or as a string concatenation operator joining two strings together if the operands are text.

ü  The % operator also performs double duty: as the ``percent"" operator when appended to a number or numeric expression, or as the C-style ``modulus"" operator when applied between two integer expressions.

ü  Operators that define equality/inequality relationships (such as == and < ) can be used to compare text strings lexically (alphabetically). In comparing mixed strings lexically, Objective Grid considers string operands to be lower than numeric operands.

ü  The conditional operator returns its second operand if its first operand evaluates True (non-zero) and returns its third operand if it evaluates False, (zero).

ü  In formulas with conditional operators, the second and third operands may be any type Objective Grid supports, including ranges. For example, the expression =@SUM(A1 ? B1..C20 : C10..D15) returns the sum of B1..C20 if A1 evaluates to non-zero; otherwise it returns the sum of C10..D15.

ü  Objective Grid accepts most arithmetic operators used in other spreadsheets like MS Excel, but there are a few differences in syntax and precedence.