aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/max.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/arduino/max.rst')
-rw-r--r--docs/source/arduino/max.rst47
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>`