diff options
| author | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 | 
|---|---|---|
| committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 | 
| commit | 5e587be27a7c3bd854b686952a5c9637a2432ff0 (patch) | |
| tree | 09d4ceeb46f19287ee874a24516c68be90c9ad8e /docs/source/lang/arithmeticcompound.rst | |
| parent | db4ff6ba53e9b702c77411ae19cd53d914a675de (diff) | |
| download | librambutan-5e587be27a7c3bd854b686952a5c9637a2432ff0.tar.gz librambutan-5e587be27a7c3bd854b686952a5c9637a2432ff0.zip | |
reorganized all the arduino/ docs into a lang/ subdirectory since
they're properly CC attributed now.
Diffstat (limited to 'docs/source/lang/arithmeticcompound.rst')
| -rw-r--r-- | docs/source/lang/arithmeticcompound.rst | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/docs/source/lang/arithmeticcompound.rst b/docs/source/lang/arithmeticcompound.rst new file mode 100644 index 0000000..aa0dc18 --- /dev/null +++ b/docs/source/lang/arithmeticcompound.rst @@ -0,0 +1,46 @@ +.. highlight:: cpp + +.. _lang-arithmeticcompound: + +Compound Arithmetic Operators (``+=`` , ``-=``, ``*=``, ``/=``) +=============================================================== + +Description +----------- + +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 | 
