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

Masking operations的更多相关文章

  1. CSharpGL(31)[译]OpenGL渲染管道那些事

    CSharpGL(31)[译]OpenGL渲染管道那些事 +BIT祝威+悄悄在此留下版了个权的信息说: 开始 自认为对OpenGL的掌握到了一个小瓶颈,现在回头细细地捋一遍OpenGL渲染管道应当是一 ...

  2. 【转】Styling And Animating SVGs With CSS

    原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS- ...

  3. Use Dynamic Data Masking to obfuscate your sensitive data

    Data privacy is a major concern today for any organization that manages sensitive data or personally ...

  4. backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.

    昨天在检查YourSQLDba备份时,发现有台数据库做备份时出现了下面错误信息,如下所示: <Exec>   <ctx>yMaint.ShrinkLog</ctx> ...

  5. sql server 里面的 dynamic Data Masking

    有时候啊,当我们存放在数据库里面的数据,需要明文存放,但是对于前台查询出来的,又不太希望明文放出去的时候(比方说客户的手机啊,邮箱啊)之类有点敏感的信息,之前通常是保存个明文,然后在前台展现的时候再特 ...

  6. HDU 5938 Four Operations(四则运算)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. ios基础篇(二十九)—— 多线程(Thread、Cocoa operations和GCD)

    一.进程与线程 1.进程 进程是指在系统中正在运行的一个应用程序,每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内: 如果我们把CPU比作一个工厂,那么进程就好比工厂的车间,一个工厂有 ...

  8. OpenCascade Modeling Algorithms Boolean Operations

    Modeling Algorithms Boolean Operations of Opencascade eryar@163.com 布尔操作(Boolean Operations)是通过两个形状( ...

  9. A.Kaw矩阵代数初步学习笔记 4. Unary Matrix Operations

    “矩阵代数初步”(Introduction to MATRIX ALGEBRA)课程由Prof. A.K.Kaw(University of South Florida)设计并讲授. PDF格式学习笔 ...

随机推荐

  1. Swift 3 点击屏幕任意位置隐藏键盘

    func hideKeyboardWhenTappedAround() { let tap: UITapGestureRecognizer = UITapGestureRecognizer(targe ...

  2. linux c++ 服务器端开发面试必看书籍

    摘自别人博客,地址:http://blog.csdn.net/qianggezhishen/article/details/45951095 打算从这开始一本一本开始看 题外话: 推荐一个 githu ...

  3. linux 下 Linux 下char转换为wchar_t 设置本地为utf-8编码 以及wchar 的输入输出

    LInux下使用mbstowcs函数可以将char转化为wchar_t函数含义:convert a multibyte string to a wide char string说明:       Th ...

  4. Ubuntu12.04中安装Oracle JDK和NetBeans的方法

    1.到官网下载jdk-7u51-linux-i586.tar.gz安装包 2.创建jvm文件夹 $sudo mkdir /usr/lib/jvm 3.将安装包解压到上述文件夹下 $-linux-i58 ...

  5. a链接嵌套无效,嵌套链接最优解决办法

    <a>不支持嵌套.例如: <a href="#1">11111111111<a href="#2">22222222222& ...

  6. BZOJ1183 Croatian2008 Umnozak 【数位DP】*

    BZOJ1183 Croatian2008 Umnozak Description 定义一个数的digit-product是它的各个位上的数字的乘积,定义一个数的self-product是它本身乘以它 ...

  7. BZOJ2342 Shoi2011 双倍回文 【Manacher】

    BZOJ2342 Shoi2011 双倍回文 Description Input 输入分为两行,第一行为一个整数,表示字符串的长度,第二行有个连续的小写的英文字符,表示字符串的内容. Output 输 ...

  8. 《DSP using MATLAB》示例Example7.14

    代码: M = 20; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l; Hrs = [1, 1, 1, zeros(1, 15), 1, 1]; % Idea ...

  9. python函数参数总结

    python中函数参数有:默认参数.关键字参数.非关键字可变长参数(元组).关键字可变长参数(字典) 默认参数:在函数声明时,指定形参的默认值,调用时可不传入改参数(使用默认值)def foo(x): ...

  10. Wordpress网站添加七牛云cdn

    1.一个搭建好的网站和七牛云账号 2.七牛云进入控制面板 3创建存储空间 4创建好了空间拿七牛给你了测试域名(但只可以使用30天)所以绑定自定义域名(这个必须是备案过的) 5.设置自定义域名(加速域名 ...