Why does 10|20 = 30 ? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 3

Why does 10|20 = 30 ?

When I search for an explanation of this operator on the internet, all I find is “Bitwise OR”. Any help? Thanks!

1st Dec 2020, 4:44 AM
Ad Lo
Ad Lo - avatar
7 Respuestas
1st Dec 2020, 4:46 AM
Simba
Simba - avatar
+ 12
bitwise OR will operate on binary representation of the numbers on both sides and perform a "logical OR" operation on each bit 10 = 01010 20 = 10100 --------------- 10|20 = 11110 which converts to 30 in binary number system
1st Dec 2020, 4:48 AM
Arsenic
Arsenic - avatar
+ 6
Simba Arsenic Thank you! Alright, I need to review my understanding of Bitwise obviously 😅😁
1st Dec 2020, 4:53 AM
Ad Lo
Ad Lo - avatar
+ 4
Ad Lo first learn how to convert decimal numbers to binary numbers.
2nd Dec 2020, 1:04 PM
Sonic
Sonic - avatar
+ 2
Kumary Harini do not spam here !
2nd Dec 2020, 9:03 AM
Arsenic
Arsenic - avatar
+ 1
Sonic Thanks! Yes, the conversion from decimal to binary is what I have not yet memorized and is where my difficulty with Bitwise begins.
2nd Dec 2020, 7:57 PM
Ad Lo
Ad Lo - avatar
- 4
'hello world'
2nd Dec 2020, 8:04 AM
Kumary Harini
Kumary Harini - avatar