aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/bytecast.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-10-25 21:15:28 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-11-17 12:44:28 -0500
commit95783b750fda95f5f4c1fac00ab24da03b31b517 (patch)
tree2b0bf89c101aa58af5796fbe76c7ec98eebbb0a5 /docs/source/arduino/bytecast.rst
parent3a9a119e9a8ce72c0e1b8fa4d3904bdf84ce355c (diff)
downloadlibrambutan-95783b750fda95f5f4c1fac00ab24da03b31b517.tar.gz
librambutan-95783b750fda95f5f4c1fac00ab24da03b31b517.zip
arduino language reference nearing completion, properly CC-BY-SA 3.0 attributed
Diffstat (limited to 'docs/source/arduino/bytecast.rst')
-rw-r--r--docs/source/arduino/bytecast.rst35
1 files changed, 22 insertions, 13 deletions
diff --git a/docs/source/arduino/bytecast.rst b/docs/source/arduino/bytecast.rst
index 71ab4aa..bf85a35 100644
--- a/docs/source/arduino/bytecast.rst
+++ b/docs/source/arduino/bytecast.rst
@@ -1,41 +1,50 @@
+.. highlight:: cpp
+
.. _arduino-bytecast:
-byte()
-======
+byte() (cast)
+=============
Description
-----------
-Converts a value to the
-`byte <http://arduino.cc/en/Reference/Byte>`_ data type.
+Converts a value to the :ref:`byte <arduino-byte>` data type.
+
+.. warning::
+ Casting to the byte type is provided for compatibility with
+ Arduino. However, ``byte`` is a non-standard type. The standard
+ C++ type for storing an 8-bit unsigned integer is ``unsigned
+ char``, and we recommend using that instead.
+ In order to cast a variable ``x`` to an ``unsigned char``, the
+ following syntax can be used::
+
+ (unsigned char)(x);
Syntax
------
-byte(x)
-
+``byte(x)``
Parameters
----------
-x: a value of any type
-
+**x**: a value of any integer type
Returns
-------
-byte
-
+The value, converted to a ``byte``. Note, however, that if the value
+is larger than the maximum value you can store in a byte (255), then
+the results might be strange and unexpected.
-See also
+See Also
--------
-
-- `byte <http://arduino.cc/en/Reference/Byte>`_
+- :ref:`arduino-byte`