Bitwise operator are powerful? Do you think? | Sololearn: Learn to code for FREE!

+11

Bitwise operator are powerful? Do you think?

bitwise https://code.sololearn.com/cf3FAHCQyMtu/?ref=app

9/21/2017 6:06:55 AM

feliciano

1 Answer

New Answer

+2

Yes, I really like them for instance for: //collect inputs If (cond1) flag|=1; // binary 001 If (cond2) flag|=2; // binary 010 If (cond3) flag|=4; // binary 100 … // Check for any condition true If (flag)… This is simple and easy. Of course, it is only useful this way, if the mentioned checks are on different code locations.