Can someone help me to understand in Python print(4 & 3)-->0 and print(5 & 4)--> 4?
Asked
Active
Viewed 201 times
-1
-
1The `&` operator is also called the `Bitwise AND operator`. – Seraph Wedd Oct 22 '19 at 09:06
-
`&` is the bitwise AND – roganjosh Oct 22 '19 at 09:06
-
1Do you understand what `&` does? if not, just read about it: https://wiki.python.org/moin/BitwiseOperators – Ofer Sadan Oct 22 '19 at 09:06
1 Answers
1
The &
operation is a bitwise ANDing each pair of corresponding bits:
- 4 & 3 == b100 & b011 == b000 = 0
- 5 & 4 == b101 & b100 == b100 = 4

goodvibration
- 5,980
- 4
- 28
- 61