aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/lang/cpp')
-rw-r--r--docs/source/lang/cpp/arithmetic.rst2
-rw-r--r--docs/source/lang/cpp/assignment.rst28
-rw-r--r--docs/source/lang/cpp/built-in-types.rst2
-rw-r--r--docs/source/lang/cpp/compoundbitwise.rst17
-rw-r--r--docs/source/lang/cpp/doublecast.rst2
-rw-r--r--docs/source/lang/cpp/enum.rst3
-rw-r--r--docs/source/lang/cpp/int.rst8
-rw-r--r--docs/source/lang/cpp/keywords.rst13
-rw-r--r--docs/source/lang/cpp/long.rst52
-rw-r--r--docs/source/lang/cpp/longcast.rst4
-rw-r--r--docs/source/lang/cpp/longlong.rst56
-rw-r--r--docs/source/lang/cpp/return.rst2
-rw-r--r--docs/source/lang/cpp/unsignedint.rst8
-rw-r--r--docs/source/lang/cpp/unsignedlong.rst41
-rw-r--r--docs/source/lang/cpp/unsignedlonglong.rst43
-rw-r--r--docs/source/lang/cpp/variables.rst2
16 files changed, 142 insertions, 141 deletions
diff --git a/docs/source/lang/cpp/arithmetic.rst b/docs/source/lang/cpp/arithmetic.rst
index 91fe22e..7e8c3fc 100644
--- a/docs/source/lang/cpp/arithmetic.rst
+++ b/docs/source/lang/cpp/arithmetic.rst
@@ -97,7 +97,7 @@ particular, on Maple, ints do not overflow (become negative) until
they reach 2,147,483,648; on the Arduino, they overflow at 32,767.
Because of this, programs running on Maple are much less likely to run
into overflow issues. The following table summarizes the sizes and
-ranges of integer datatypes on the Maple (the ranges of long long
+ranges of integer datatypes on the Maple (the ranges of ``long long``
types are approximate):
.. _lang-arithmetic-int-sizes:
diff --git a/docs/source/lang/cpp/assignment.rst b/docs/source/lang/cpp/assignment.rst
index b6ad4d5..f9430b4 100644
--- a/docs/source/lang/cpp/assignment.rst
+++ b/docs/source/lang/cpp/assignment.rst
@@ -15,47 +15,38 @@ 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
- senVal = analogRead(0); // store the (digitized) input voltage at analog pin 0 in 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 )
+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.
-
+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
--------
-
-- `if (comparison operators) <http://arduino.cc/en/Reference/If>`_
-- `char <http://arduino.cc/en/Reference/Char>`_
-- `int <http://arduino.cc/en/Reference/Int>`_
-- `long <http://arduino.cc/en/Reference/Long>`_
-
+- :ref:`if <lang-if>`
+- :ref:`char <lang-char>`
+- :ref:`int <lang-int>`
+- :ref:`long long <lang-longlong>`
.. rubric:: Footnotes
@@ -66,5 +57,4 @@ See Also
<http://icu-project.org/docs/papers/cpp_report/the_anatomy_of_the_assignment_operator.html>`_
for more information.
-
.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/built-in-types.rst b/docs/source/lang/cpp/built-in-types.rst
index 1323db8..a7349e6 100644
--- a/docs/source/lang/cpp/built-in-types.rst
+++ b/docs/source/lang/cpp/built-in-types.rst
@@ -33,7 +33,7 @@ Integral types
.. cpp:type:: long
- 64-bit integer value.
+ 32-bit integer value.
.. cpp:type:: long long
diff --git a/docs/source/lang/cpp/compoundbitwise.rst b/docs/source/lang/cpp/compoundbitwise.rst
index a4bbb24..8231130 100644
--- a/docs/source/lang/cpp/compoundbitwise.rst
+++ b/docs/source/lang/cpp/compoundbitwise.rst
@@ -31,8 +31,8 @@ value of ``y``::
x &= y; // equivalent to x = x & y;
You can use any integer variable for ``x`` (i.e., any variable of type
-``int``, ``long``, ``char``, ``byte``, etc.). You can use either an
-integer variable or any :ref:`integer value
+``int``, ``char``, ``byte``, ``long long``, etc.). You can use either
+an integer variable or any :ref:`integer value
<lang-constants-integers>` (like ``3`` or ``0x20``) for ``y``.
Before doing an example of ``&=``, let's first review the Bitwise AND
@@ -115,9 +115,9 @@ its old value bitwise ORed with the value of ``y``::
x |= y; // equivalent to x = x | y;
You can use any integer variable for ``x`` (i.e., any variable of type
-``int``, ``long``, ``char``, ``byte``, etc.). You can use either an
-integer variable or any integer value (like ``3`` or ``0x20``) for
-``y``. (This works the same way as :ref:`compound bitwise AND
+``int``, ``char``, ``long long`` etc.). You can use either an integer
+variable or any integer value (like ``3`` or ``0x20``) for ``y``.
+(This works the same way as :ref:`compound bitwise AND
<lang-compoundbitwise-and>`\ , ``&=``).
Before doing an example of ``|=``, let's first review the Bitwise OR
@@ -178,12 +178,11 @@ will be equal to its old value bitwise XORed with the value of ``y``::
x ^= y; // equivalent to x = x ^ y;
You can use any integer variable for ``x`` (i.e., any variable of type
-``int``, ``long``, ``char``, ``byte``, etc.). You can use either an
+``int``, ``char``, ``long long``, etc.). You can use either an
integer variable or any integer value (like ``3`` or ``0x20``) for
``y``. (This works the same way as :ref:`&=
-<lang-compoundbitwise-and>` and :ref:`\|=
-<lang-compoundbitwise-or>`; in fact, these three operators all
-work the same in this way).
+<lang-compoundbitwise-and>` and :ref:`\|= <lang-compoundbitwise-or>`;
+in fact, these three operators all work the same in this way).
Before doing an example of ``^=``, let's first review the Bitwise
XOR operator, ``^``::
diff --git a/docs/source/lang/cpp/doublecast.rst b/docs/source/lang/cpp/doublecast.rst
index 511fe24..16a9907 100644
--- a/docs/source/lang/cpp/doublecast.rst
+++ b/docs/source/lang/cpp/doublecast.rst
@@ -12,7 +12,7 @@ data type. Here is an example::
double d = double(x); // d now holds 2.0, a double value
The value ``x`` can be of any type. However, if ``x`` is not a number
-(like an ``int`` or ``long``), you will get strange results.
+(like an ``int`` or ``long long``), you will get strange results.
See the :ref:`double <lang-double>` reference for details about the
precision and limitations of ``double`` values on the Maple.
diff --git a/docs/source/lang/cpp/enum.rst b/docs/source/lang/cpp/enum.rst
index ba82383..b6409eb 100644
--- a/docs/source/lang/cpp/enum.rst
+++ b/docs/source/lang/cpp/enum.rst
@@ -18,8 +18,7 @@ which has values ``HOT``, ``COMFY``, and ``COLD``::
enum weather {HOT, COMFY, COLD};
Once you've defined this type, you can create variables of type
-``weather``, in the same way you would with an :ref:`int <lang-int>`
-or a :ref:`long <lang-long>`::
+``weather``, in the same way you would with an :ref:`int <lang-int>`::
// create a weather variable named theWeather, with value COMFY:
weather theWeather = COMFY;
diff --git a/docs/source/lang/cpp/int.rst b/docs/source/lang/cpp/int.rst
index ca75f75..3e96b69 100644
--- a/docs/source/lang/cpp/int.rst
+++ b/docs/source/lang/cpp/int.rst
@@ -24,6 +24,10 @@ arithmetic operations work mostly as you'd expect. There can be an
dealing with the :ref:`bitshift right operator (>>)
<lang-bitshift>`, however.
+.. _lang-long:
+
+The ``long`` type is a synonym for ``int``.
+
Here is an example of declaring an ``int`` variable named ``ledPin``,
then giving it value 13::
@@ -56,8 +60,8 @@ See Also
- :ref:`unsigned int <lang-unsignedint>`
- :ref:`char <lang-char>`
- :ref:`unsigned char <lang-unsignedchar>`
-- :ref:`long <lang-long>`
-- :ref:`unsigned long <lang-unsignedlong>`
+- :ref:`long long <lang-longlong>`
+- :ref:`unsigned long long <lang-unsignedlonglong>`
- :ref:`Integer Constants <lang-constants-integers>`
- :ref:`Variables <lang-variables>`
diff --git a/docs/source/lang/cpp/keywords.rst b/docs/source/lang/cpp/keywords.rst
index e3bc20d..f21cd0d 100644
--- a/docs/source/lang/cpp/keywords.rst
+++ b/docs/source/lang/cpp/keywords.rst
@@ -89,11 +89,11 @@ Types
The following keywords are used for built-in types.
- :ref:`bool <lang-booleanvariables>`
-- :ref:`lang-char`
-- :ref:`lang-double`
-- :ref:`lang-float`
-- :ref:`lang-int`
-- :ref:`lang-long`
+- :ref:`char <lang-char>`
+- :ref:`double <lang-double>`
+- :ref:`float <lang-float>`
+- :ref:`int <lang-int>`
+- :ref:`long <lang-long>`
- :ref:`short <lang-built-in-types-integral>`
- :ref:`void <lang-void>` (not really a type, but used in the absence
of one)
@@ -109,8 +109,7 @@ Qualifiers
variables; it has other uses not documented here.
- ``unsigned`` is used to specify an unsigned integral type.
- Examples: :ref:`lang-unsignedint`, :ref:`lang-unsignedchar`,
- :ref:`lang-unsignedlong`.
+ Examples: :ref:`lang-unsignedint`, :ref:`lang-unsignedchar`.
- :ref:`volatile <lang-volatile>` is useful when declaring variables
that may be modified by external interrupts.
diff --git a/docs/source/lang/cpp/long.rst b/docs/source/lang/cpp/long.rst
deleted file mode 100644
index d8498c0..0000000
--- a/docs/source/lang/cpp/long.rst
+++ /dev/null
@@ -1,52 +0,0 @@
-.. highlight:: cpp
-
-.. _lang-long:
-
-``long``
-========
-
-The ``long`` data type stores extended size integer values. You can
-use a ``long`` when your values are too large to fit into an :ref:`int
-<lang-int>`. A ``long`` occupies 8 bytes of memory. This yields a
-range of approximately -9.2×10^18 to 9.2×10^18 (that's 9.2 billion
-billion, or about 92 million times the number of stars in the Milky
-Way galaxy). The exact range of a ``long`` on the Maple is from
--9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, or -2^63 to
-(2^63-1). A ``long`` it is subject to the same :ref:`overflow issues
-<lang-variables-rollover>` as any numeric data type.
-
-Here's an example of declaring a long (see :ref:`integer constants
-<lang-constants-integers-u-l>` for an explanation of the "L" at the end of the
-number)::
-
- // Speed of light in nanometers per second (approximate).
- long c = 299792458000000000L;
-
-The general syntax for declaring an ``long`` variable named ``var``,
-then giving it value ``val``, looks like::
-
- long var = val;
-
-This is identical to the ``int`` syntax, with ``long`` replacing
-``int``.
-
-Note that ``long`` values will still :ref:`overflow
-<lang-int-overflow>`, just like ``int`` values, but their much
-larger range makes this less likely to happen.
-
-The downside to using a ``long`` instead of an ``int`` (besides the
-extra storage) is that :ref:`arithmetic <lang-arithmetic>` operations
-on ``long``\ s will take slightly longer than on ``int``\ s.
-
-See Also
---------
-
-- :ref:`char <lang-char>`
-- :ref:`unsigned char <lang-unsignedchar>`
-- :ref:`int <lang-int>`
-- :ref:`unsigned int <lang-unsignedint>`
-- :ref:`unsigned long <lang-unsignedlong>`
-- :ref:`Integer Constants <lang-constants-integers>`
-- :ref:`Variables <lang-variables>`
-
-.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/longcast.rst b/docs/source/lang/cpp/longcast.rst
index 2b92345..f588fc6 100644
--- a/docs/source/lang/cpp/longcast.rst
+++ b/docs/source/lang/cpp/longcast.rst
@@ -21,7 +21,7 @@ precision and limitations of ``long`` variables on the Maple.
See Also
--------
-- :ref:`long <lang-long>`
-
+- :ref:`long <lang-long>`
+- :ref:`long long <lang-longlong>`
.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/longlong.rst b/docs/source/lang/cpp/longlong.rst
new file mode 100644
index 0000000..0ba56ed
--- /dev/null
+++ b/docs/source/lang/cpp/longlong.rst
@@ -0,0 +1,56 @@
+.. highlight:: cpp
+
+.. _lang-longlong:
+
+``long long``
+=============
+
+The ``long long`` data type stores extended size integer values. You
+can use a ``long long`` when your values are too large to fit into an
+:ref:`int <lang-int>`. A ``long long`` occupies 8 bytes of memory.
+This yields a range of approximately -9.2×10^18 to 9.2×10^18 (that's
+9.2 billion billion, or about 92 million times the number of stars in
+the Milky Way galaxy). The exact range of a ``long long`` on the
+Maple is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807,
+or -2^63 to (2^63-1). A ``long long`` it is subject to the same
+:ref:`overflow issues <lang-variables-rollover>` as any numeric data
+type.
+
+A synonym for the ``long long`` type is ``int64``.
+
+Here's an example of declaring a long long (see :ref:`integer
+constants <lang-constants-integers-u-l>` for an explanation of the
+"LL" at the end of the number)::
+
+ // Speed of light in nanometers per second (approximate).
+ long long c = 299792458000000000LL;
+
+The general syntax for declaring an ``long long`` variable named ``var``,
+then giving it value ``val``, looks like::
+
+ long long var = val;
+
+This is identical to the ``int`` syntax, with ``long long`` (or, at
+your option, ``int64``) replacing ``int``.
+
+Note that ``long long`` values will still :ref:`overflow
+<lang-int-overflow>`, just like ``int`` values, but their much larger
+range makes this less likely to happen.
+
+The downside to using a ``long long`` instead of an ``int`` (besides
+the extra storage) is that :ref:`arithmetic <lang-arithmetic>`
+operations on ``long long``\ s will take slightly longer than on
+``int``\ s.
+
+See Also
+--------
+
+- :ref:`char <lang-char>`
+- :ref:`unsigned char <lang-unsignedchar>`
+- :ref:`int <lang-int>`
+- :ref:`unsigned int <lang-unsignedint>`
+- :ref:`unsigned long long <lang-unsignedlonglong>`
+- :ref:`Integer Constants <lang-constants-integers>`
+- :ref:`Variables <lang-variables>`
+
+.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/return.rst b/docs/source/lang/cpp/return.rst
index 7b5039e..b4ef5fd 100644
--- a/docs/source/lang/cpp/return.rst
+++ b/docs/source/lang/cpp/return.rst
@@ -21,7 +21,7 @@ Syntax:
In the second case, ``value`` should have a type which is the same as
the return type of the function, or be convertible to it (like an
-``int`` to a ``long``, etc.; see :ref:`this note
+``int`` to a ``double``, etc.; see :ref:`this note
<lang-arithmetic-typeconversion>` for some references).
Examples:
diff --git a/docs/source/lang/cpp/unsignedint.rst b/docs/source/lang/cpp/unsignedint.rst
index f6311da..ad3e2f2 100644
--- a/docs/source/lang/cpp/unsignedint.rst
+++ b/docs/source/lang/cpp/unsignedint.rst
@@ -31,6 +31,10 @@ that an ``unsigned int`` will "underflow" at 0, and "overflow" at
x--; // x now contains 4,294,967,295; rolled over "left to right"
x++; // x now contains 0; rolled over "right to left"
+.. _lang-unsignedlong:
+
+The ``unsigned long`` type is a synonym for ``unsigned int``.
+
Here is an example of declaring an ``unsigned int`` variable named
``ledPin``, then giving it value 13::
@@ -47,8 +51,8 @@ See Also
- :ref:`int <lang-int>`
- :ref:`char <lang-char>`
- :ref:`unsigned char <lang-unsignedchar>`
-- :ref:`long <lang-long>`
-- :ref:`unsigned long <lang-unsignedlong>`
+- :ref:`long long <lang-longlong>`
+- :ref:`unsigned long long <lang-unsignedlonglong>`
- :ref:`Integer Constants <lang-constants-integers>`
- :ref:`Variables <lang-variables>`
diff --git a/docs/source/lang/cpp/unsignedlong.rst b/docs/source/lang/cpp/unsignedlong.rst
deleted file mode 100644
index 14a4fc3..0000000
--- a/docs/source/lang/cpp/unsignedlong.rst
+++ /dev/null
@@ -1,41 +0,0 @@
-.. highlight:: cpp
-
-.. _lang-unsignedlong:
-
-``unsigned long``
-=================
-
-An unsigned version of the :ref:`long <lang-long>` data type. An
-``unsigned long`` occupies 8 bytes of memory; it stores an integer
-from 0 to 2^64-1, which is approximately 1.8×10^19 (18 quintillion, or
-18 billion billion).
-
-Like an :ref:`unsigned int <lang-unsignedint>`, an ``unsigned long``
-won't store negative numbers; it is also subject to the same
-:ref:`overflow issues <lang-int-overflow>` as any integral data type.
-
-Here is an example of declaring an ``unsigned long`` variable named
-``c``, then giving it value 299,792,458,000,000,000 (see :ref:`integer
-constants <lang-constants-integers-u-l>` for an explanation of the "L"
-at the end of the number)::
-
- // Speed of light in nanometers per second (approximate).
- unsigned long c = 299792458000000000L;
-
-The general syntax for declaring an ``unsigned long`` variable named
-``var``, then giving it value ``val``, looks like::
-
- unsigned long var = val;
-
-See Also
---------
-
-- :ref:`long <lang-long>`
-- :ref:`int <lang-int>`
-- :ref:`unsigned <lang-unsignedint>`
-- :ref:`char <lang-char>`
-- :ref:`unsigned char <lang-unsignedchar>`
-- :ref:`Integer Constants <lang-constants-integers>`
-- :ref:`Variables <lang-variables>`
-
-.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/unsignedlonglong.rst b/docs/source/lang/cpp/unsignedlonglong.rst
new file mode 100644
index 0000000..910b7e4
--- /dev/null
+++ b/docs/source/lang/cpp/unsignedlonglong.rst
@@ -0,0 +1,43 @@
+.. highlight:: cpp
+
+.. _lang-unsignedlonglong:
+
+``unsigned long long``
+======================
+
+An unsigned version of the :ref:`long long <lang-longlong>` data type.
+An ``unsigned long long`` occupies 8 bytes of memory; it stores an
+integer from 0 to 2^64-1, which is approximately 1.8×10^19 (18
+quintillion, or 18 billion billion).
+
+A synonym for the ``unsigned long long`` type is ``uint64``.
+
+Like an :ref:`unsigned int <lang-unsignedint>`, an ``unsigned long
+long`` won't store negative numbers; it is also subject to the same
+:ref:`overflow issues <lang-int-overflow>` as any integral data type.
+
+Here is an example of declaring an ``unsigned long long`` variable
+named ``c``, then giving it value 299,792,458,000,000,000 (see
+:ref:`integer constants <lang-constants-integers-u-l>` for an
+explanation of the "ULL" at the end of the number)::
+
+ // Speed of light in nanometers per second (approximate).
+ unsigned long long c = 299792458000000000ULL;
+
+The general syntax for declaring an ``unsigned long long`` variable named
+``var``, then giving it value ``val``, looks like::
+
+ unsigned long long var = val;
+
+See Also
+--------
+
+- :ref:`long long <lang-longlong>`
+- :ref:`int <lang-int>`
+- :ref:`unsigned <lang-unsignedint>`
+- :ref:`char <lang-char>`
+- :ref:`unsigned char <lang-unsignedchar>`
+- :ref:`Integer Constants <lang-constants-integers>`
+- :ref:`Variables <lang-variables>`
+
+.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/variables.rst b/docs/source/lang/cpp/variables.rst
index e6da0c9..336d5ab 100644
--- a/docs/source/lang/cpp/variables.rst
+++ b/docs/source/lang/cpp/variables.rst
@@ -44,7 +44,7 @@ Here are a few examples of declaring variables of different types::
int lightSensVal;
char currentLetter;
- unsigned long speedOfLight = 186000UL;
+ unsigned long long speedOfLight = 186000ULL;
char errorMessage = {"choose another option"}; // see string
Naming Variables