Hello, The main reason of newbies' fear from XOR is bad reference in the problem statements to explain XOR and other bitwise operations (Authors usually put Wikipedia reference) and newbies mostly can't understand what's XOR, today I wanna explain something about bitwise operations for this group of coders with simple language :

1- Bitwise OR :

In this operation the system compares bits in same index in binary representation and if at least one of the bits was $$$1$$$ it returns $$$1$$$ otherwise $$$0$$$, Also it is written as `|`

in C++.

For example :

Bitwise OR of $$$6$$$ and $$$3$$$ is :

$$$6 = 110$$$ in binary representation and $$$3 = 011$$$.

$$$6$$$ | $$$3 = 7 = (110$$$ | $$$011 = 111)$$$

**Note : If in any index a number doesn't have enough bits system supposes that there's a $$$0$$$ bit in that index in binary representation of that number**.

2- Bitwise AND :

As it's guessable from it's name if all bits in same index were $$$1$$$ system return $$$1$$$ otherwise $$$0$$$, Also it's written as `&`

in C++.

For example :

Bitwise AND of $$$10$$$ and $$$3$$$ is :

$$$10 = 1001$$$ and $$$3 = 0011$$$

$$$10$$$ & $$$3 = 1 = 1001$$$ & $$$0011 = 0001$$$.

3- Bitwise XOR :

In this operation system compares bits in same index and if odd number of them were $$$1$$$ it returns $$$1$$$ otherwise $$$0$$$, Also it is written as `xor`

or `^`

in C++.

For example :

Bitwise XOR of $$$3$$$ and $$$5$$$ and $$$8$$$ is :

$$$8 = 1000, 5 = 0101, 3 = 0011$$$.

$$$8$$$ ^ $$$5$$$ ^ $$$3 = 14 = 1000$$$ ^ $$$0101$$$ ^ $$$0011 = 1110$$$.

**Problems**

I hope it would be helpful for you 💗 💗 (BTW if you noticed any typo let me know).

**PS : As people say in the comments I've added some educational problems about this topic, If you had problems about this topic please write down in the comments Thanks.**

There are only 10 types of people...

1.those who know ternary system

2.those who doesn't know ternary system

3.those who thought this is a joke about binary system

If possible, could you pls attach few lists of problems based on binary operators for beginner to medium level.

++

Auto comment: topic has been updated by hunter_of_alts (previous revision, new revision, compare).