Default
Google

Operators: Bitwise Operators

Applies To: C++Builder 1 or higher
Category: C++ Language

Bitwise operators are used to manipulate bits in an integer data type:
 
& : and
 
If corresponding bits are 1, it returns 1. Otherwise, it returns 0. Example: 1101 & 1011 is 1001
 
| : inclusive or
 
If corresponding bits are 0, it returns 0. Otherwise, it returns 1. Example: 1101 | 1001 is 1101
 
^ : exclusive or
 
If only one of the corresponding bits is 1, it returns 1. Otherwise, it returns 0. Example: 1011 ^ 0010 is 1001
 
~ : complement
 
Converts 0 to 1 and 1 to 0. Example: ~0110 is 1001
 
>>: right shift
 
Shifts a number right by a number of bits. Example: 1100 >> 2 is 0011
 
<<: left shift
 
Shifts a number left by a number of bits. Example: 0011 << 2 is 1100

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange