# Combining Elements

C/C++ expressions may be combined in the following ways:

• Arithmetic operators

Addition (+), subtraction (−), multiplication (*), division (/), and modulo operation (%) may be used as well as the unary minus (−) to form a numeric expression. For example:

```EVALUATE 17 + 4
EVALUATE 3*@a + 1  !@a denotes a debugger variable
EVALUATE -@result    !@result denotes a debugger variable```
• Relational and logical operators

Two expressions may be compared using the following operators: greater than (>), less than (<), greater or equal (>=), less or equal (<=), equal (==), not equal (!=). The logical operators and (&&), or (||), and not (!) are available, too. For example:

```IF @id > @lastid THEN STEP 1
IF @x == 0  &&  @x != a + 1 THEN EVALUATE @X```
• Parentheses

Parentheses may be used to change the precedence of operators (see below) in the usual way. For example:

`EVALUATE ( 2 * ( @n + 1 ) ) % ( @m - 1 )`
• Type casts

Every expression has a type which depends on its elements and operators. For example, a*b is of type integer if a and b are integers; if a or b is a floating point number, so is the result of the multiplication. Types may be changed deliberately by writing the desired type (in parentheses) in front of the expression to be converted. For example:

```EVALUATE VAR1  ! Result: 0x544E4E49
EVALUATE (long long) VAR1  ! 1414417993 with type cast```
• Bitwise logical operators

The following operators consider their operands to be bitfields rather than numbers or strings: bitwise and (&), bitwise or (|), bitwise exclusive or (^), bitwise negation (~). The bits may be shifted to the left (high-order) side (<<) or to the right side (>>). For example:

`EVALUATE 0x12345&24`

The address of an object may be obtained with the '&' operator. If the result of an expression is to be taken as an address, the '*' operator is appropriate. For example:

```SHOW SYMBOL *funptr
SHOW SYMBOL &main```
• Structure operators

Array members are accessed using brackets. Structure members are accessed with the '.' operator. The pointer-to-structure operator (->) is available, too. For example:

```SHOW SYMBOL inputline[12]
EVALUATE emp.birthdate.month
EVALUATE dateptr->month```

The operators mentioned above have the following precedence and associativity:

Operator

Associativity

( ) [ ] . ->

left to right

! ~ - (type) * &

right to left

* / %

left to right

+ −

left to right

<< >>

left to right

> < >= <=

left to right

== !=

left to right

&

left to right

^

left to right

|

left to right

&&

left to right

||

left to right

Operators on the same line have the same precedence. Rows are displayed in order of decreasing precedence; for example, a + b % c is equal to a + (b % c) because '%' has a higher precedence than '+'.

Associativity describes the way a row of operators is grouped. For example, a + b + c is equal to (a + b) + c because '+' is grouped left to right.