0% found this document useful (0 votes)
2 views

Bitwise Operators

The document explains various bitwise operators including AND, OR, X-OR, left shift, right shift, and one's complement, which operate exclusively on integers. It provides a truth table for these operations and examples of how to use them in C programming with integer variables. The examples illustrate the results of applying these operators to specific integer values.

Uploaded by

janhavik053
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Bitwise Operators

The document explains various bitwise operators including AND, OR, X-OR, left shift, right shift, and one's complement, which operate exclusively on integers. It provides a truth table for these operations and examples of how to use them in C programming with integer variables. The examples illustrate the results of applying these operators to specific integer values.

Uploaded by

janhavik053
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Bitwise Operators

& Bitwise AND Op.

| Bitwise OR

^ Bitwise X-OR (Exclusive OR)

<< Bitwise Left Shift Op.

>> Bitwise Right Shift Op.

~ Bitwise One's Compliment Op. ===> It is UNARY in nature.

NOTE : Bitwise operators OPERATES only upon the INTEGERS(int , char)

1 - ON /TRUE
0 - OFF/FALSE

Truth Table

Bit1 Bit2 Bit1 & Bit2 Bit1 | Bit2 Bit1 ^ Bit2


1 1 1 1 0
1 0 0 1 1
0 1 0 1 1
0 0 0 0 0

Bit ~Bit
1 0
0 1

int a=27, b=22;


int ans = a & b;
printf("Value of ans = %d\n", ans);

a = 27 == 11011
& b = 22 == 10110
-------------------------------------
ans == 10010

int a=27, b=22;


int ans = a | b;
printf("Value of ans = %d\n", ans);

a = 27 == 11011
| b = 22 == 10110
-------------------------------------
ans == 11111

int a=27, b=22;


int ans = a ^ b;
printf("Value of ans = %d\n", ans);
a = 27 == 11011
^ b = 22 == 10110
-------------------------------------
ans == 01101

You might also like