Home Segments Index Top Previous Next

317: Sidetrip

You can, in principle, position two plus signs or two minus signs as suffixes, rather than as prefixes. In either position, the plus signs or minus signs cause a variable's value to change, but if the incremented or decremented variable is embedded in a larger expression, the value handed over differs. If a variable is prefixed, the value handed over is the new, incremented value; if a variable is suffixed, the value handed over is the old, original value.

Suppose that the value of counter is 3. Then, the value of the expression --counter is 2, and the new value of counter is 2. On the other hand, again supposing that the value of counter is 3, the value of the expression counter-- is 3, even though the new value of counter is 2.