– – (decrement)

[Compound Operators]

説明

Decrements the value of a variable by 1.

Syntax

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

Parameters

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

Returns

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

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール