Skip to main content
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

Bit-wise Operator-:


C has the special feature to manipulate with bits,in some application we require manipulation on bits such as system programming.C has bit-wise operator to support bit-wise operation ,possible bit-wise operator available in C are as follow-:
(a-) Once Complement-: This operator is denoted as " ~ " [tilde].This operator is unary in nature, i.e. it require single operand to perform an operation.It is one of the method used for data encryption.
It works on binary pattern and convert all the one's into zero and zero's into one.
Example-: consider the following bit pattern:-
                      110101001
Hence,its once complement will be 001010110.
(b-) Bit-wise Left Shift-: This operator is denoted as " << ".This operator is binary in nature,i.e. it require two operands to perform an operation.The left operand is variable and right operand is in binary pattern,the bits are shifted to left and for each bit shifted ,a zero is added to the right of the bit pattern.
Example-: x=10101101
So, x<<10101101 will be 01011010.
(c-) Bit-wise Right Shift-:This operator is denoted as " >> ".This operator is binary in nature,i.e. it require two operands to perform an operation.The left operand is variable and right operand is in binary pattern,the bits are shifted to right and for each bit shifted ,a zero is added to the left of the bit pattern.
Example-: x=00101101
So, x>>10101101 will be 00010110ads
(d-) Bit-wise AND-: This operator is represented by the symbol "&".It works on two operands,while operating.These two operands are compared on bit by bit basis.Both the operand should be of same data type.Among the two operands,second operand is known as "AND MASK".This operator operates on pair of bits to yield a resultant bit.
F-BIT  S-BIT  R-BIT
   0           0         0
   1           0          0 
   0           1          0
    1          1          1
Example-: 11000011   Given Bit
                   00001000  AND MASK
                   11101011   Resultant Bit
(e-) Bit-wise OR-: This operator is denoted as " |  ".It is usually used to put ON a particular bit in a bit pattern.It works on two operands,while operating.These two operands are compared on bit by bit basis.Both the operand should be of same data type.Among the two operands,second operand is known as "AND MASK".This operator operates on pair of bits to yield a resultant bit.
F-BIT  S-BIT  R-BIT
   0           0         0
   1           0          1
   0           1          1
    1          1          1
Example-: 11000011   Given Bit
                   00001000  AND MASK
                   11001011   Resultant Bit
(f-)  Bit-wise XOR-: This operator is denoted as " ^ ". It is also called as an exclusive OR operator. The value of resulting bit after performing X-OR operation of two bit are as follow-:
F-BIT  S-BIT  R-BIT
   0           0         0
   1           0         1
   0           1         1
    1          1          0
Example-: 00001011   Given Bit
                   00010010  AND MASK
                   00011000   Resultant Bit
 Watch The Below Video 

ads


Comments

Post a Comment

Please do not enter any spam link in the comment box.


Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey