Reference Language | Libraries | Comparison | Changes
这些运算符返回两个操作数的和,差,乘积,商. 这些运算是根据操作数的数据类型来计算的,比如 9和4都是int类型,所以9 / 4
结果是 2
.这也就代表如果运算结果比数据类型所能容纳的范围要大的话,就会出现溢出.(例如. 1加上一个整数 int类型 32,767 结果变成-32,768). 如果操作数是不同类型的,结果是"更大"的那种数据类型.
如果操作数中的其中一个是 float类型或者double类型, 就变成了浮点数运算.
y = y + 3; x = x - 7; i = j * 6; r = r / 5;
result = value1 + value2; result = value1 - value2; result = value1 * value2; result = value1 / value2;
value1: 任何常量或者变量
value2: 任何常量或者变量
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.