BitWise Logical Operators
Types of BitWise Logical Operators are explained as follows:-
The BitWise logical Operators are & , |, ~ and ^.The Biltwise Logical Operators are applied to each and every bit of each opernd.
1.The BitWise AND:-The BitWise AND operator produces value 1 if the value of both the operands is also 1.A 0 is produced in all other case.
For Example:-
applying AND Operation to 42,15
00101010
& 0001111
---------------------------
00001010
---------------------------
It is equal 10
2.The BitWise OR:-The BitWise OR Operator produces a 1 bit if either of operands bit value is 1.A 0 would be produced if both operands bits are 0 otherwise a 1 bit is produced.
For Example:-
Applying OR Operation to 42,15
00101010
| 00001111
---------------------------
00101111
--------------------------
It is equal to 47
3.The BitWise NOT:-The BitWise NOT inverts the value of bits of its operand remember there is only one operand.If value of bit is 1 then it is changed to 0 and vice versa.
For Example:- The Binary value of 42 is 00101010
and applying Bitwise NOT we get
~ (00101010) = 11010101
11010101 in decimal is equal to 213 that is (255-42)
4.The BitWise XOR:-The BitWise XOR produces a bit value of 1 when both values of operand bits are different.Produces 0 in all other cases.
For Example:-
Applying XOR to 42,15
=> 00101010
^ 00001111
-----------------------------
00100101
-----------------------------
It is equal to 37
Useful Links:-
Assignment Operators
Arithmetic Operators
Logical operators
Relational Operators
Conditional Operators
Bitwise Operator Intro
Bitwise Left shift Operator
Bitwise Right shift Operator
Sponsored Links :-
Get Your SCJP preparation Kit free!!!!!!!
Get Your SCWCD preparation Kit free!!!
Are you Intelligent check here


















0 comments:
Post a Comment
Post a Comment