– – (decrement)

[Compound Operators]


Decrements the value of a variable by 1.


x--; // decrement x by one and returns the old value of x
--x; // decrement x by one and returns the new value of x


x: variable. Allowed data types: intlong (possibly unsigned).


The original or newly decremented value of the variable.

Example Code

x = 2;
y = --x;  // x now contains 1, y contains 1
y = x--;  // x contains 0, but y still contains 1

Language Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Your email address will not be published. Required fields are marked *