aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/max.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-11-28 11:23:33 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-11-28 11:23:33 -0500
commit5e587be27a7c3bd854b686952a5c9637a2432ff0 (patch)
tree09d4ceeb46f19287ee874a24516c68be90c9ad8e /docs/source/lang/max.rst
parentdb4ff6ba53e9b702c77411ae19cd53d914a675de (diff)
downloadlibrambutan-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/max.rst')
-rw-r--r--docs/source/lang/max.rst63
1 files changed, 63 insertions, 0 deletions
diff --git a/docs/source/lang/max.rst b/docs/source/lang/max.rst
new file mode 100644
index 0000000..7dbf6a7
--- /dev/null
+++ b/docs/source/lang/max.rst
@@ -0,0 +1,63 @@
+.. highlight:: cpp
+
+.. _lang-max:
+
+max(x, y)
+=========
+
+Description
+-----------
+
+(Macro) Calculates the maximum of two numbers.
+
+
+
+Parameters
+----------
+
+**x**: the first number; may be any number or numeric expression.
+
+**y**: the second number; may be any number or numeric expression.
+
+
+Returns
+-------
+
+The larger of the two parameter values.
+
+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 :ref:`min()
+ <lang-min>` is used to constrain the upper end of the range.
+
+Warning
+-------
+
+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 operations outside max()
+
+Arduino Compatibility
+---------------------
+
+The Maple version of ``max()`` is compatible with Arduino.
+
+See Also
+--------
+
+- :ref:`min() <lang-min>`
+- :ref:`constrain() <lang-constrain>`
+
+
+.. include:: cc-attribution.txt