+= , -= , *= , /=

描述

一个变数与常数或变数做数学运算。+= 运算符只是一个方便的扩展语法,如下所示。

语法


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.