+= , -= , *= , /=
描述
一個變數與常數或變數做數學運算。+= 運算符只是一個方便的擴展語法,如下所示。
語法
x += y; // 相當於 x = x + y;
x -= y; // 相當於 x = x - y;
x *= y; // 相當於 x = x * y;
x /= y; // 相當於 x / y;
參數
x
:任意變數型態
y
:任意變數型態或常數
範例
x = 2; x += 4; // x 現在是 6 x -= 3; // x 現在是 3 x *= 10; // x 現在是 30 x /= 2; // x 現在是 15
本頁由熱血青年 LBU 譯自英文版。
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.