why do we need bitwise operation such as XOR | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

why do we need bitwise operation such as XOR

bitwise

10th Jun 2021, 1:17 PM
Omar
Omar - avatar
2 Answers
0
bitwise operators operate at bit level on whole numbers: they are the fastest operations to be done on whole numbers... xor operator works as: 1 xor 1 = 0 1 xor 0 = 1 0 xor 1 = 1 0 xor 0 = 0 so xor is used as a mask wich invert bits where bit is set and leave bits unchanged where bit is not set... at a very low level, all instructions are done using combined/chained bitwise operators (each is a specialized electronic transistor wich compound nowadays microprocessors by more of 10 billions)
10th Jun 2021, 4:34 PM
visph
visph - avatar