Bitwise Complement (~)
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.
Related Video: https://www.youtube.com/watch?v=a45kwVu3IU8&feature=youtu.be
Next Topic: Bit wise Left shift operator (<<)
Previous Topic: Bitwise OR Operator (|)
No comments:
Post a Comment