0

I want to do a bitwise & operator in my program. I don't know why return 0. I do bit and bit.

& operator. https://code.sololearn.com/cW0KgH08e4hG/?ref=app

11th Jun 2020, 6:18 AM
Malick Diagne
Malick Diagne - avatar
2 odpowiedzi
+ 3
Do you know about how bitwise & works? The result is correct. What result you were expecting? Bitwise operators check bits of both operands one by one. If both the bits are 1 , corresponding bit in result is set to 1 otherwise 0. 1 -> 01 2 -> 10 1&2 -> 00
11th Jun 2020, 6:30 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
Neba Emmanuel , && isn't bitwise operator. It's a logical operator. && - Logical. & - Bitwise.
11th Jun 2020, 6:34 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar