From 5e587be27a7c3bd854b686952a5c9637a2432ff0 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Sun, 28 Nov 2010 11:23:33 -0500 Subject: reorganized all the arduino/ docs into a lang/ subdirectory since they're properly CC attributed now. --- docs/source/lang/long.rst | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 docs/source/lang/long.rst (limited to 'docs/source/lang/long.rst') diff --git a/docs/source/lang/long.rst b/docs/source/lang/long.rst new file mode 100644 index 0000000..8a19b2b --- /dev/null +++ b/docs/source/lang/long.rst @@ -0,0 +1,55 @@ +.. highlight:: cpp + +.. _lang-long: + +long +==== + +Description +----------- + +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 +`. 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 +` as any numeric data type. + +Here's an example of declaring a long (see :ref:`integer constants +` 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 +`, 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 ` operations +on ``long``\ s will take slightly longer than on ``int``\ s. + +See Also +-------- + +- :ref:`char ` +- :ref:`unsigned char ` +- :ref:`int ` +- :ref:`unsigned int ` +- :ref:`unsigned long ` +- :ref:`Integer Constants ` +- :ref:`Variables ` + +.. include:: cc-attribution.txt -- cgit v1.2.3