zoukankan      html  css  js  c++  java
  • Masking operations

    Using a mask, multiple bits in a nibble, byte, words can be set either on, off or inverted from on to off (or vice versa) in a single bitwise operation.

    More detail is in

    https://en.wikipedia.org/wiki/Mask_(computing)

    1) Masking bits to 1

    To turn certain bits on, we need to use OR.

    To make sure a bit is on, OR can be used as 1.

    To make sure a bit is off, OR can be used as 0.

    ex:

         0000 1111
    OR   0010 0010
         ------------
         0010 1111
    

      

    2) Masking bits to 0

    To turn certain bits off, we need to use AND.

    To make sure a bit is off, AND can be used as 0. 

    ex: 

        0000 1111
    AND 0010 0010
    -------------
        0000 0010
    

      

    3) Toggling bit values

    If the original bit is 0, it returns 0 XOR 1 to 1.

    If the original bit is 1, it returns 1 XOR 1 to 0.

    EX:

        0000 1111
    XOR 0010 0010
    -------------
        0010 1101
  • 相关阅读:
    iOS中过滤html文档中的标签
    十六进制函数转换UIColor对象
    vue使用echarts
    vue打包部署
    charels代理跨域访问接口
    vue 使用highcharts
    vue配置跨域
    命令行
    安装nvm
    vsCode个人设置
  • 原文地址:https://www.cnblogs.com/KennyRom/p/6426136.html
Copyright © 2011-2022 走看看