Important Notice:

Course Content
Operators, Expression & Python Statement (Chapter-4) M3-R5.1
About Lesson
Bitwise Operators:-

            पायथन में, बिटवाइज ऑपरेटरों का उपयोग integer पर बिटवाइज calculation करने के लिए किया जाता है। Integer को पहले बाइनरी में परिवर्तित किया जाता है और फिर bit by bit storage किया जाता है इसलिए इसका नाम बिटवाइज ऑपरेटर है। फिर result decimal format में return किया जाता है।

उदाहरण के लिए माना x = 10 तथा y = 4

तो बाइनरी फॉरमेट में x = 0000 1010 तथा y = 0000 0100

Operators

Meaning

Example

&

bitwise AND

x & y = 0 (0000 0000)

|

bitwise OR

x | y = 14 (0000 1110)

~

bitwise NOT

~ x = -11 (1111 0101)

^

bitwise XOR

x ^ y = 14 (0000 1110)

>> 

Bitwise right shift

x >> 2 = 2 (0000 0010)

<< 

Bitwise left shift

x << 2 = 40 (0010 1000)

Bitwise NOT :     -(a+1)

         

                                      Bitwise operator Truth Table

 

Bitwise Operators:-

            In Python, bitwise operators are used to perform bitwise calculations on integers. Integer is first converted to binary and then stored bit by bit hence its name is bitwise operator. Then the result is returned in decimal format.

For example, let x = 10 and y = 4.

So in binary format x = 0000 1010 and y = 0000 0100

Bitwise NOT :     -(a+1)

Operators

Meaning

Example

&

bitwise AND

x & y = 0 (0000 0000)

|

bitwise OR

x | y = 14 (0000 1110)

~

bitwise NOT

~ x = -11 (1111 0101)

^

bitwise XOR

x ^ y = 14 (0000 1110)

>> 

Bitwise right shift

x >> 2 = 2 (0000 0010)

<< 

Bitwise left shift

x << 2 = 40 (0010 1000)

Bitwise operator Truth Table

error: Content is protected !!