diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-21 10:27:37 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-21 10:27:37 -0500 |
commit | c45bccad44187da27505cf5808424e709e3f54a1 (patch) | |
tree | 18a459a50f8d0551ba046e30462c93999d982725 /docs/source/arduino/bitwisexornot.rst | |
parent | 84fd2532a7f23d20354ff590790b3f892cb7e7d7 (diff) | |
parent | d5ad2a27f4e69e6cc9324331945937c983c30366 (diff) | |
download | librambutan-c45bccad44187da27505cf5808424e709e3f54a1.tar.gz librambutan-c45bccad44187da27505cf5808424e709e3f54a1.zip |
Merge branch 'master' into debug-serialusb.
Chose debug-serialusb version in cases of conflict.
Conflicts:
libmaple/usb/usb_callbacks.c
Diffstat (limited to 'docs/source/arduino/bitwisexornot.rst')
-rw-r--r-- | docs/source/arduino/bitwisexornot.rst | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/docs/source/arduino/bitwisexornot.rst b/docs/source/arduino/bitwisexornot.rst deleted file mode 100644 index 25389cb..0000000 --- a/docs/source/arduino/bitwisexornot.rst +++ /dev/null @@ -1,51 +0,0 @@ -.. _arduino-bitwisexornot: - -Bitwise NOT (~) -=============== - -The bitwise NOT operator in C++ is the tilde character ~. Unlike & -and \|, the bitwise NOT operator is applied to a single operand to -its right. Bitwise NOT changes each bit to its opposite: 0 becomes -1, and 1 becomes 0. For example: - - - -:: - - 0 1 operand1 - - - -:: - - ---------- - 1 0 ~ operand1 - - - -:: - - int a = 103; // binary: 0000000001100111 - int b = ~a; // binary: 1111111110011000 = -104 - - - -You might be surprised to see a negative number like -104 as the -result of this operation. This is because the highest bit in an int -variable is the so-called sign bit. If the highest bit is 1, the -number is interpreted as negative. This encoding of positive and -negative numbers is referred to as two's complement. For more -information, see the Wikipedia article on -`two's complement. <http://en.wikipedia.org/wiki/Twos_complement>`_ - - - -As an aside, it is interesting to note that for any integer x, ~x -is the same as -x-1. - - - -At times, the sign bit in a signed integer expression can cause -some unwanted surprises. - - |