What are bitwise operators?

后端 未结 9 1778
闹比i
闹比i 2020-11-22 02:05

I\'m someone who writes code just for fun and haven\'t really delved into it in either an academic or professional setting, so stuff like these bitwise operators really esca

9条回答
  •  不思量自难忘°
    2020-11-22 02:44

    It might help to think of it this way. This is how AND (&) works:

    It basically says are both of these numbers ones, so if you have two numbers 5 and 3 they will be converted into binary and the computer will think

             5: 00000101
             3: 00000011
    

    are both one: 00000001 0 is false, 1 is true

    So the AND of 5 and 3 is one. The OR (|) operator does the same thing except only one of the numbers must be one to output 1, not both.

提交回复
热议问题