diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-10-25 21:15:28 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-17 12:44:28 -0500 |
commit | 95783b750fda95f5f4c1fac00ab24da03b31b517 (patch) | |
tree | 2b0bf89c101aa58af5796fbe76c7ec98eebbb0a5 /docs/source/arduino/max.rst | |
parent | 3a9a119e9a8ce72c0e1b8fa4d3904bdf84ce355c (diff) | |
download | librambutan-95783b750fda95f5f4c1fac00ab24da03b31b517.tar.gz librambutan-95783b750fda95f5f4c1fac00ab24da03b31b517.zip |
arduino language reference nearing completion, properly CC-BY-SA 3.0 attributed
Diffstat (limited to 'docs/source/arduino/max.rst')
-rw-r--r-- | docs/source/arduino/max.rst | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/docs/source/arduino/max.rst b/docs/source/arduino/max.rst index 375625c..1e2c619 100644 --- a/docs/source/arduino/max.rst +++ b/docs/source/arduino/max.rst @@ -1,3 +1,5 @@ +.. highlight:: cpp + .. _arduino-max: max(x, y) @@ -6,19 +8,16 @@ max(x, y) Description ----------- -Calculates the maximum of two numbers. +(Macro) Calculates the maximum of two numbers. Parameters ---------- -x: the first number, any data type - - - -y: the second number, any data type +**x**: the first number; may be any number or numeric expression. +**y**: the second number; may be any number or numeric expression. Returns @@ -26,8 +25,6 @@ Returns The larger of the two parameter values. - - Example ------- @@ -36,36 +33,28 @@ Example sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20 // (effectively ensuring that it is at least 20) -Note ----- - -Perhaps counter-intuitively, max() is often used to constrain the -lower end of a variable's range, while min() is used to constrain -the upper end of the range. - - +.. note:: Perhaps counter-intuitively, max() is often used to + constrain the lower end of a variable's range, while :ref:`min() + <arduino-min>` is used to constrain the upper end of the range. Warning ------- -Because of the way the max() function is implemented, avoid using -other functions inside the brackets, it may lead to incorrect -results - - - -:: +Because of the way ``max()`` is implemented, avoid using other +functions inside the parentheses. It may lead to incorrect results:: max(a--, 0); // avoid this - yields incorrect results - + a--; // use this instead - - max(a, 0); // keep other math outside the function + max(a, 0); // keep other operations outside max() +Arduino Compatibility +--------------------- +The Maple version of ``max()`` is compatible with Arduino. -See also +See Also -------- - -- `min <http://arduino.cc/en/Reference/Min>`_\ () -- `constrain <http://arduino.cc/en/Reference/Constrain>`_\ () +- :ref:`min() <arduino-min>` +- :ref:`constrain() <arduino-constrain>` |