What are bitwise operators?

后端 未结 9 1785
闹比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:41

    To break it down a bit more, it has a lot to do with the binary representation of the value in question.

    For example (in decimal):
    x = 8
    y = 1
    
    would come out to (in binary):
    x = 1000
    y = 0001
    
    From there, you can do computational operations such as 'and' or 'or'; in this case:
    x | y = 
    1000 
    0001 |
    ------
    1001
    
    or...9 in decimal
    

    Hope this helps.

提交回复
热议问题