-- (Self-decrease)

From Microduino Wiki
Jump to: navigation, search

-- (Self-decrease)

  • Description

Increasing or decreasing a variable

  • Syntax
 
x++;  //x self-adds 1, and return the original value of x.
++x;  // x self-adds 1, and return the new value of x.
 
x--;  // x self-decreases 1, and return the original value of x.
--x;  //x self-decreases 1, and return the new value of x. 
  • Parameters
x: in or long(maybe unsigned)

Return

The original or new value after the self-addition or self-decrease of a variable.

  • Example
x = 2;
y = ++x;      // Now, x=3, y=3
y = x--;      // Now, x=2, y=3

[Return to Arduino Syntax Manual]