0% found this document useful (0 votes)
55 views2 pages

Bitwise Operators Explained: Complement, Shift

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views2 pages

Bitwise Operators Explained: Complement, Shift

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Bitwise Complement (~):


 The Bitwise Complement operator converts every bit 1 becomes 0 and 0
becomes 1.
 The bitwise operator is a unary operator.

 The above is the example of complement operator.


 The variable is declared and assigned value to it.
 Assign value a=6 ( Binary value is 0101)
 After using complement operator the binary value is 1010.
 It will store the value in result and then it will print.

[Link] Right Shift(>>>):


 The Unsigned Right shift operator shifts all bits to the right, falling the
leftmost bits with [Link] the right shift ,which can fill the sign
bit,>>>always fills with 0.
 First make 1’s complement and 2’s complement.
 Firstly it will convert 1’s complement to the assign value and
2’scomplement.
 Them it will be shifted towards to right (>>>)
[Link] shift(<<):
 The left shift operator shifts all bits to the left by a certain number of
positions, filling the rightmost bits with 0.

 Value assigned to a variable and then perform the left shift operator
 The left shift operator is used to shift towards the left.

You might also like