Examples of Bitwise
operations
C programming language allows us to perform bit level
operation using bitwise operators (AND, OR, etc.).
Example of bitwise
AND operation
Bitwise AND operation on two numbers 30 and 25 is given
below:
30 in binary is 00011110
25 in binary is 00011001
Bitwise AND operation on 30 and 25 is as
under:
00011110
& 00011001
=========
00011000 i.e. 24
Answer: 30 AND
25 = 24
Example of bitwise OR operation
Bitwise OR
operation on two numbers 30 and 25 is given below:
30 in binary is 00011110
25 in binary is 00011001
Bitwise OR operation on 30 and 25 is as
under:
00011110
OR 00011001
=========
00011111 i.e. 31
Answer: 30
OR 25 = 31
No comments:
Post a Comment