diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-11-29 01:49:26 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-29 01:49:26 -0500 |
commit | ee35f641687d0d3159c15eea5ad80d71efff4f82 (patch) | |
tree | d58e470a42623a1fba3eccbab324a26316d60398 /source/lang/compoundarithmetic.rst | |
parent | d9cbd78e29d42e70bb46641dd43ee0772c8c975f (diff) | |
download | librambutan-ee35f641687d0d3159c15eea5ad80d71efff4f82.tar.gz librambutan-ee35f641687d0d3159c15eea5ad80d71efff4f82.zip |
Finished converting the Arduino docs
Diffstat (limited to 'source/lang/compoundarithmetic.rst')
-rw-r--r-- | source/lang/compoundarithmetic.rst | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/lang/compoundarithmetic.rst b/source/lang/compoundarithmetic.rst new file mode 100644 index 0000000..420f1db --- /dev/null +++ b/source/lang/compoundarithmetic.rst @@ -0,0 +1,44 @@ +.. highlight:: cpp + +.. _lang-compoundarithmetic: + +Compound Arithmetic Operators (``+=`` , ``-=``, ``*=``, ``/=``) +=============================================================== + +These oparators perform a mathematical operation on a variable with +another constant or variable. These operators are just a convenient +shorthand:: + + x += y; // equivalent to the expression x = x + y; + x -= y; // equivalent to the expression x = x - y; + x *= y; // equivalent to the expression x = x * y; + x /= y; // equivalent to the expression x = x / y; + +Here is an example:: + + int x = 2; + int y = 10; + + x += 4; // x now contains 6 + x -= 3; // x now contains 3 + x *= y; // x now contains 30 + x /= 2; // x now contains 15 + x += max(20, 6); // x now contains 35 + x -= sq(5); // x now contains 15 + +Parameters +---------- + +**x**: a numeric variable + +**y**: a numeric variable, number constant, or any other expression +that evaluates to a number (e.g. call to a function that returns a +number). + +See Also +-------- + +- :ref:`Arithmetic operators <lang-arithmetic>` + + +.. include:: cc-attribution.txt |