Bitwise logical operators and Truth tables. - C++ Operator

C++ examples for Operator:Bit Operator

Introduction

OperatorMeaning
& Bitwise AND
| Bitwise inclusive OR
^ Bitwise exclusive OR
~ Bitwise 1's complement

Truth tables.

Bitwise AND (&)

0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1

Bitwise inclusive OR ( |)

0 | 0 = 0
0 | 1 = 1
1  | 0 = 1
1 | 1 = 1

Bitwise exclusive OR (^)

0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0

Bitwise 1's complement (~)

~0 = 1
~1 = 0

Related Tutorials