Monday, 27 May 2019

Bitwise Complement (~)

Bitwise Complement (~)

a=25









Read the remainders from bottom to up
11001



Complement of a
a  = 1 1 0 0 1
~a= 0 0 1 1 0

Now we need to convert from binary to decimal:



0
0
1
1
0



24
23
22
21
20



16
8
4
2
1



0
0
4
2
0

Add 1’s: ~a=4+2=6
Here 16 is leadig with ‘0’ zero are no significance, it is not necessary to take .

This operator gives the complement form of a given number. This operator symbol is~, which is pronounced as tilde . It performs bitwise compliment each bit in the number is complimented, it is Unary operator, it has only one operand.




Next Topic: Bit wise Left shift operator (<<)
Previous Topic: Bitwise OR Operator (|)

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...