contents.gifindex.gifprev0.gifnext1.gif

Sequence of Evaluation

The results of using an operator depend on the sequence of evaluation. Without parentheses, operations are performed from left to right. Consider the following two equations. In the first, the constant 1 is converted to a set; in the second, the 1 is treated as a single bit.

Equation 1: The first operation is [a, b] & 1, so 1 is converted to a set [0, 1].

[x1, y1] = [a, b] & 1 & d
= ([a, b] & 1 ) & d
= ([a, b] & [0, 1]) & d
= ([a & 0, b & 1]) & d
= [ 0 , b ] & d
= [0 & d, b & d]
= [0, b & d]

x1 = 0
y1 = b & d

Equation 2: The first operation is 1 & d, so one is treated as a single bit.

[x2,y2] = 1 & d & [a, b]
= (1 & d) & [a, b]
= d & [a, b]
= [d & a, d & b]

x2 = a & d
y2 = b & d

If you are unsure about the interpretation of an equation, try the following hints:

Fully parenthesize your equation. Errors can occur if you are not familiar with the precedence rules in Operator Priorities.

Write out numbers as sets of 1s and 0s instead of as decimal numbers. If the width is not what you expected, you will get an error message.


See Also

More on Sequence of Evaluation