Bitwise Operators (बिटवाइज़ ऑपरेटर) :-
Bitwise Operators (बिटवाइज़ ऑपरेटर) वे Operators हैं जिनका उपयोग integers की individual bits (0 और 1) पर operations करने के लिए किया जाता है।
Python में Bitwise Operators किसी number को उसके Binary Form (द्विआधारी रूप) में process करते हैं।
English
Bitwise Operators are used to perform operations on the individual bits of integer values. They work directly with the binary representation (0 and 1) of numbers.
Bitwise Operators are mainly used in low-level programming, data processing, flags, masking, and system-level operations.
Syntax -
The Bitwise AND Operator (&) compares corresponding bits of two numbers.
Bitwise AND Operator (&) दो numbers की corresponding bits की तुलना करता है।
यदि दोनों bits 1 हैं, तो result 1 होता है, अन्यथा 0 होता है।
Truth Table -
The Bitwise OR Operator (|) compares corresponding bits of two numbers.
Bitwise OR Operator (|) में यदि किसी भी position पर कम से कम एक bit 1 हो, तो result 1 होता है।
Truth Table -The Bitwise XOR Operator (^) returns 1 when the corresponding bits are different.
Bitwise XOR Operator (^) में दोनों bits अलग होने पर result 1 और समान होने पर 0 होता है।
Truth Table -The Bitwise NOT Operator (~) reverses each bit of a number.
Bitwise NOT Operator (~) प्रत्येक bit को उलट देता है:
The Left Shift Operator (<<) shifts the bits of a number to the left by the specified number of positions.
Left Shift Operator (<<) bits को left side में shift करता है।
Example -The Right Shift Operator (>>) shifts the bits of a number to the right by the specified number of positions.
Right Shift Operator (>>) bits को right side में shift करता है।
Example -