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. TF随笔-7

    求平均值的函数 reduce_mean axis为1表示求行 axis为0表示求列 >>> xxx=tf.constant([[1., 10.],[3.,30.]])>> ...

  2. Android 开发 Tip 17 -- 为什么getBackground().setAlpha(); 会影响别的控件?

    转载请注明出处:http://blog.csdn.net/crazy1235/article/details/75670018 http://www.jb51.net/article/110035.h ...

  3. iOS 解决上传100张图片内存奔溃问题

    最近项目需求,从相册中提取100张图片,然后上传到服务器.前提是图片不能压缩.因为要将图片信息采集出来制作出3D模型.所以必须是高清图片. 先看下代码 [NetWorking uploadWithUr ...

  4. times(NULL) Segmentation fault

    ****************************************************************************** * times(NULL) Segment ...

  5. 【NodeJs】入门笔记一

    忙乎了两周,把一个后台模型项目完成了,整个过程又进步不少,私喜一下. 暂时可以悠闲两天,又一次把node教程拿出来,每次都看一点点,积少成多吧. 查了很多资料,觉得从<Node入门>开始看 ...

  6. 像黑客一样!Chrome 完全键盘操作指南(原生快捷键 + Vimium 插件)

    有那么一波小伙伴,多数时候都不需要用到鼠标,通常他们正好是“黑客”.当你开始使用键盘操作一切时,便能体会到无需用鼠标瞄准按钮时的干脆,无需在键盘和鼠标之间移动手时的轻松. Chrome 原生自带大量快 ...

  7. NET Core中基于Generic Host来实现后台任务

    NET Core中基于Generic Host来实现后台任务 https://www.cnblogs.com/catcher1994/p/9961228.html 目录 前言 什么是Generic H ...

  8. tableview小结-初学者的问题

    初学者的问题主要集中在,下面几个问题: 一.几个函数总是不被调用:例如: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInS ...

  9. 携程 决赛 第一题 Crossword

    //真是郁闷的一晚上//比赛时看到这题是就感觉会做,感觉思路清晰 就去准备找第二题 ,因为感觉第二题是个经典问题,(我不会计算几何),就去搜索了下,然后找到求最小面积的,改来改去,一直Wa// 然后就 ...

  10. Mac根据端口号查询进程

    sudo lsof -i :8080