+ 1

If && is AND operator in c++, so what '&' is ? And how to use it ?

8th Mar 2018, 4:28 PM
Ali Kafi
Ali Kafi - avatar
3 ответов
+ 16
& is the bitwise AND. it simply converts numbers to binary, do its job, and then convert output back to initial numeric system. 5 & 7 -> 101 & 111 = 101 -> 5 4 & 1 -> 100 & 001 = 000 -> 0 Rules (vertically): AND 1 & 1 = 1 1 & 0 = 0 0 & 1 = 0 0 & 0 = 0 OR 1 | 1 = 1 1 | 0 = 1 0 | 1 = 1 0 | 0 = 0 XOR(one or other but not both) 1 ^ 1 = 0 1 ^ 0 = 1 0 ^ 1 = 1 0 ^ 0 = 0
8th Mar 2018, 4:38 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
Than you @ValentinHacker and excuse me, i'm biginner, should i know or learn binary of deferent numbers, to use the bitwise functions !?
8th Mar 2018, 5:06 PM
Ali Kafi
Ali Kafi - avatar