NA
0000-0000
1000-0000
1111-1111
1*2^7=128
1*2^6=64
1*2^5=32
1*2^4=16
1*2^3=8
1*2^2=4
1*2^1=2
1*2^0=1
0000-0010
0000-0000
0000-0001
1111-1110
0000-0010
1111-1110
0000-0001
0000-0010
private static final int DISABLE = 0x0;
private static final int CLICKABLE = 1;
private static final int LONG_CLICKABLE = 2;
private static final int DRAGGABLE = 4;
private static final int START = 8;
private static final int END = 16;
public static void main(String[] args) {
int mState = 11;
mState |= DISABLE;
mState &= ~CLICKABLE;
mState |= LONG_CLICKABLE;
mState |= DRAGGABLE;
mState |= START;
mState &= ~END;
System.out.println("mState = " + ((mState & DISABLE) == DISABLE));
System.out.println("mState = " + ((mState & CLICKABLE) == CLICKABLE));
System.out.println("mState = " + ((mState & LONG_CLICKABLE) == LONG_CLICKABLE));
System.out.println("mState = " + ((mState & DRAGGABLE) == DRAGGABLE));
System.out.println("mState = " + ((mState & START) == START));
System.out.println("mState = " + ((mState & END) == END));
}
如上分析:
定义常量,需要是2的N次幂
中间变量mState可以是任意的值
经由mState和常量有如下变换
mState |= DISABLE;
那么之后再有如下变换
((mState & DISABLE) == DISABLE)结果为true
如果上述有此变换
mState &= ~DISABLE;
((mState & DISABLE) == DISABLE)结果为false
NA的更多相关文章
- Sa yo na ra
总想记点些什么. 都快忘了当初是为什么来到这里呢... 2014年10月,友人给我介绍了一门编程竞赛ACM,并给我演示了一下A+B.于是我知道了ACM的含义. 2014年12月,开始水入门题. 201 ...
- R语言 奇怪的NA
> 1+NA [1] NA > NA==1 [1] NA > c(NA,1:50) [1] NA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
- R中,去掉dataframe中的NA行
R中使用complete.cases 和 na.omit来去掉包含NA的行 现在有个一data.frame datafile如下所示 Date sulfate nitrate ID 1 ...
- R: NULL, NA, and NaN
NaN (“Not a Number”) means 0/0 NA (“Not Available”) is generally interpreted as a missing value and ...
- R中NA和NaN的区别
NA表示的是缺失数据,missing data NaN表示无意义的数据,Not a Number, Inf-Inf Inf表示正无穷大 -Inf表示负无穷大
- R语言,NA,NAN
好莫名其妙的结果 is.na() #NA得不到的值is.nan() #NAN不可能的值is.infinite() #无穷的 x1<-NA x2<-0/0x3<-1/0 is.na(x ...
- Exception in thread "main" java.lang.NoClassDefFoundError: UDP_Receive (wrong na me: com/ray/net/UDP_Receive)
一.事件经过 今晚学习java网络编程,在eclipse中写了两个个java文件,一个发送端UDP_Send2.java,一个接收端UDP_Receive.java.实现发送端键盘录入信息,通过UDP ...
- 广州大学华软软件学院——NA视频下载
准备工具: 360极速浏览器(不要认错图标了): 浏览器视频下载插件: 第一步:安装浏览器插件 1.打开浏览器 2.解压,找到插件文件: 3.把插件拖到浏览器中: 4.添加,然后就完成了插件安装 查看 ...
- 胡na娜、少年和恩师-写在甲午冬的仅仅言片语及感想
[写在全新为移动互联网而生的Zoomla!逐浪CMS2 x2.1公布前] 恩师, 他来到这个乡村中学,带着自己的书.吉它和理想, 用自己最好的三年青春浇灌了这一代人, 在我辍学时,给我鼓舞,帮助我继续 ...
- R语言数据框中,用0替代NA缺失值
1.用0替代数据框中的缺失值NA 生成数据框: > m <- matrix(sample(c(NA, :), , replace = TRUE), ) > d <- as.da ...
随机推荐
- docker WARNING: bridge-nf-call-iptables is disabled 处理
在CentOS中 vim /etc/sysctl.conf net.bridge.bridge-nf-call-ip6tables = net.bridge.bridge-nf-call-iptabl ...
- 选择Nodejs的N个理由
选择Nodejs的N个理由 作者 马德奎 发布于 2014年9月25日 Caleb Madrigal是 来自美国密尔沃基市的一名软件顾问.四年前,他在听说“将JavaScript用作服务器端语言”这样 ...
- Tom and paper
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5224 题意: 给出矩形的面积,求出最小的周长. 样例: Sample Input 3 2 7 12 ...
- 利用Jquery给当前页或者跳转后页面的导航栏添加选中后样式
具体的样式有两种情况,一种是直接给当前页面添加特殊样式,当网页刷新或者跳转到下一页后,样式消失:另一种情况是即使刷新页面后样式仍然有效. 直接上代码: 第一种情况: 在CODE上查看代码片派生到我的代 ...
- select()函数 timval问题
如果select调用中设置了等待时间,那么每次调用时都需要重新对这个时间赋值.例如: struct timval tv; while(1) { ........; tv.tv_sec = 2; ...
- Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle ...
- ArrayList类的实现
package other; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import ...
- win10添加打印机--无法访问指定设备,路径或文件。。
win10添加打印机无法访问指定设备,路径或文件..后来发现很多按钮点击多说无法访问指定设备,路径或文件.. 解决添加打印机问题: 在搜索栏中搜索:print (从这里添加) 彻底解决: 添加环境变量 ...
- Jquery省市区三级联动案例
//Java部分代码 public String province() throws Exception { List<Province> list=cityBiz.showProvinc ...
- thinkphp上传至服务器后模板无法解析原因
前几日做好的响应式静态页面上传至虚拟空间,打开网址地址出现: 模板不存在:./app/Home/View/Index/index.html 错误位置 FILE: /home/u333385714/pu ...