Thursday, June 26

What are BITWISE LOGICAL OPERATOR used in Object oriented programming language


There are certain situations wherein bitwise operators are to be performed, and this is possible in C++. The following operators are used for the bitwise logical decision making. Normally, most of the high level programming languages do not support the bitwise operations. The bitwise operators are one of the salient features of C++...... Some of them are as follows:
(i) Bitwise AND : The bitwise AND operation will be carried out between two bit patterns of the two operands as:
VARIABLE>> VALUE BINARY>> PATTERN
x >>>>>>>>>>5>>>>>>>>>>>>>> 0101
y >>>>>>>>>>2>>>>>>>>>>>>>> 0010
x & y>>>>>>> 0>>>>>>>>>>>>>> 0000
a >>>>>>>>>>6>>>>>>>>>>>>>> 0110
b >>>>>>>>>>3>>>>>>>>>>>>>> 0011
a & b>>>>>>> 2>>>>>>>>>>>>>> 0010

To generate a 1 bit in the result, bitwise AND need a 1 in both numbers. Normally it is called as masking operator and one may select particular pattern as either a one or a zero and it selects certain specific bits and ignores the others...
(ii) Bitwise OR : In this case result is 1 if any of the bit in the two operand is 1 , as....
VARIABLE >>VALUE BINARY >>PATTERN
x >>>>>>>>>>5 >>>>>>>>>>>>>0101
y >>>>>>>>>>2>>>>>>>>>>>>> 0010
x or y>>>>>>> 7>>>>>>>>>>>>> 0111

(iii) Bitwise exclusive OR : In this operation result is 1 when any of the bit in the two operand is 1 ,but not 1 at the same time. as:
VARIABLE>> VALUE>> BINARY PATTERN
a >>>>>>>>>6 >>>>>>>>0110
b >>>>>>>>>3>>>>>>>> 0011
a ^ b >>>>>>5 >>>>>>>>0101
(iv) Bitwise complement : It basically converts all 1's to 0's and all 0's to 1's as:
VARIABLE>>VALUE >>BINARY PATTERN
x >>>>>>>>>6 >>>>>>>0110
~x >>>>>>>>9 >>>>>>>1001
(v) Shift operations : Basically shift operation shifts the bits either in the left or in the right direction, just dropping the digit at one end and placing a 0 in the beginning....
for a left shift << operator is used
example : suppose x = 00100001 (binary)
x >> 3 shifts the bit pattern to 3 place to right, that is 00000100 etc......
This ends our section on Bitwise logical operators , our next segment will be 'special operators' , do come as it is very much important................

0 comments:

Followers

Archive

 

Money ,Entertainment and Education. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com