aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/cpp/assignment.rst
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2014-08-27 17:36:11 -0400
committerbnewbold <bnewbold@robocracy.org>2014-08-27 17:42:22 -0400
commit34b766c9d5f778762069938c71e052fa40455d1c (patch)
tree3a2b77e636b222fecff6366218cf7845029afecf /docs/source/lang/cpp/assignment.rst
parent746d6fecf86572c9fe95dbbffdf541a8d3875dd0 (diff)
parentadd7e54ccaf61859874527feda2b51ea172ce697 (diff)
downloadlibrambutan-34b766c9d5f778762069938c71e052fa40455d1c.tar.gz
librambutan-34b766c9d5f778762069938c71e052fa40455d1c.zip
merge libmaple docs ("leaflabs-docs") into ./docs
In the past, libample documentation was forked out of this repository because the documentation had increased in scope. For the librambutan, and the rambutan project in general, we will try to keep documentation closer to the source code, so the librambutan-specific documentation should live here. Other sections of leaflabs-docs will be culled in a following commit. This merge attempts to maintain history by using a subtree strategy. Followed directions at: http://nuclearsquid.com/writings/subtree-merging-and-you/ Full history for files should be accessible using the "--follow" flag to git log, eg: git log --follow docs/source/adc.rst It should be possible to pull patches from leaflabs-docs with: git pull -s subtree leaflabs-docs master ... at least until the docs in this repository diverge significantly.
Diffstat (limited to 'docs/source/lang/cpp/assignment.rst')
-rw-r--r--docs/source/lang/cpp/assignment.rst60
1 files changed, 60 insertions, 0 deletions
diff --git a/docs/source/lang/cpp/assignment.rst b/docs/source/lang/cpp/assignment.rst
new file mode 100644
index 0000000..6379298
--- /dev/null
+++ b/docs/source/lang/cpp/assignment.rst
@@ -0,0 +1,60 @@
+.. highlight:: cpp
+
+.. _lang-assignment:
+
+Assignment Operator (``=``)
+===========================
+
+Stores the value to the right of the equal sign in the variable to
+the left of the equal sign.
+
+The single equal sign in the C++ programming language is called the
+assignment operator. It has a different meaning than in algebra
+class, where it indicated an equation or equality. The assignment
+operator tells the microcontroller to evaluate whatever value or
+expression is on the right side of the equal sign, and store it in
+the variable to the left of the equal sign [#fgross]_.
+
+Example
+-------
+
+::
+
+ int sensVal; // declare an integer variable named sensVal
+ sensVal = analogRead(0); // store the (digitized) input voltage at analog pin 0 in sensVal
+
+Programming Tips
+----------------
+
+The variable on the left side of the assignment operator (``=`` sign)
+needs to be able to hold the value stored in it. If it is not large
+enough to hold a value, the value stored in the variable will be
+incorrect.
+
+Don't confuse the assignment operator ``=`` (single equal sign) with
+the comparison operator ``==`` (double equal signs), which evaluates
+whether two expressions are equal.
+
+Arduino Compatibility
+---------------------
+
+Assignments on the Maple are identical to those on Arduino.
+
+See Also
+--------
+
+- :ref:`if <lang-if>`
+- :ref:`char <lang-char>`
+- :ref:`int <lang-int>`
+- :ref:`long long <lang-longlong>`
+
+.. rubric:: Footnotes
+
+.. [#fgross] Experienced C++ programmers know this to be an
+ oversimplification of what happens when the variable on the left
+ hand side is an object. See Richard Gillam's wonderful and scary
+ `The Anatomy of the Assignment Operator
+ <http://icu-project.org/docs/papers/cpp_report/the_anatomy_of_the_assignment_operator.html>`_
+ for more information.
+
+.. include:: /arduino-cc-attribution.txt