Expressions Menu: Operators

The Operators submenu lists JavaScript logical operators that you can use to modify your expression. If you have done any scripting or other programming, you will probably be familiar with many of these already. To enter an operator into your expression, simply choose it from the submenu.

The table below lists the logical operators in the Operators menu and describes their functionality. The terms “LHS” and “RHS” refer to the subexpressions on the Left Hand Side and Right Hand Side of the operator, respectively.
Menu Item Description
Assign (=) Assigns the RHS value to the LHS variable.
Equal (==) Evaluates to true if the LHS and RHS are equal.
Not equal (!=) Evaluates to true if the LHS and RHS are not equal.
Greater than (>) Evaluates to true if the LHS is greater than the RHS.
Greater than or equal to (>=) Evaluates to true if the LHS is greater than or equal to the RHS.
Less than (<) Evaluates to true if the LHS is less than the RHS.
Less than or equal to (<=) Evaluates to true if the LHS is less than or equal to the RHS.
Logical AND (&&) Evaluates to true if the LHS and RHS are both true.
Logical OR (||) Evaluates to true if either the LHS or RHS is true. (If the LHS is true, the RHS isn’t evaluated.)
Logical NOT (!) Evaluates to true if the RHS is false. Note that this is a unary operator—there is no LHS.
Bitwise AND (&) Produces a new value whose bits are set when the corresponding bits in the LHS and RHS are both set. 0xf0a6 & 0xcd0f evaluates to 0xc006, for example.
Bitwise OR (|) Produces a new value whose bits are set when either of the corresponding bits in the LHS and RHS is set. 0xf0a6 | 0xcd0f evaluates to 0xfdaf, for example.
Bitwise XOR (^) Produces a new value whose bits are set when only one (but not both) of the corresponding bits in the LHS and RHS is set. 0xf0a6 ^ 0xcd0f evaluates to 0x3da9, for example.
Bitwise NOT (~) Produces a new value whose bits are inverted with respect to the RHS. Note that this is a unary operator—there is no LHS. ~0xcd0f evaluates to 0x32f0, for example.
Shift left (<<) Produces a new value by shifting the bits of the LHS n positions to the left, where n is the value of the RHS. The new rightmost bits will be 0s. 0xcd0f << 1 evaluates to 0x19a1e, for example.
Shift right (>>) Produces a new value by shifting the bits of the LHS n positions to the right, where n is the value of the RHS. The new leftmost bits will be 0s. 0xcd0f >> 1 evaluates to 0x6687, for example.
Modulus (%) Returns the remainder resulting from the division of LHS by RHS. 8 % 5 evaluates to 3, for example (8 divided by 5 is 1 with the remainder 3).
In-line conditional (?:) Used in the form cond ? expr1 : expr2, where cond is an expression that evaluates to a Boolean value. Evaluates to expr1 if cond is true, or expr2 if cond is false. For example, the expression x > 5 ? 2 : 1 evaluates to 2 when x is greater than 5 and evaluates to 1 when x is not greater than 5. This is sometimes referred to as a ternary conditional, since it has three operands.

The most basic arithmetic operators are not included in the menu. They are addition (+), subtraction (-), multiplication (*), and division (/). Enter these operators from the keyboard.

Related concepts
Expressions Menu: Data Federation Functions

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.