+ 3

Where, when and for what we can use Bitwise operators in while code.

https://www.sololearn.com/post/23827/?ref=app FYI, I know what is Bitwise operators. I need real time examples!! Thanks

13th Aug 2018, 2:57 PM
prakash@softvars
prakash@softvars - avatar
2 odpowiedzi
+ 1
One of the usages is to encode several error codes into one return code. For example: 00000001 -> parameter1 is missing 00000010 -> parameter2 is missing 00000100 -> connection pool is empty 00001000 -> file not found ... If you want to combine several error codes (binary numbers in the examples above) into one return code, you can OR all of the needed error codes. If you want to check whether the return code include a particular error, you just AND the return code with that error code. If the result is not 0, it means that your result include that error...
14th Aug 2018, 2:29 PM
Rocky Lee
Rocky Lee - avatar
+ 1
I happened to use bit-bitwise ops to check if i hadn't used some items in a list of given items. You can take a look at the method findAuxiliaryPeg() in the following code snippet. https://code.sololearn.com/cDhJwN4VHk0B/?ref=app
18th Aug 2018, 3:56 AM
Rocky Lee
Rocky Lee - avatar