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 ...
随机推荐
- Linux软件安装为什么名字不一样
一.说安装 1.安装 yacc :# yum install byacc 2.安装 glib: :# yum install glibc 3.安装 wireshark :# yum install w ...
- pthread_creat()解析及需注意的地方
函数声明 int pthread_create(pthread_t*restrict tidp,const pthread_attr_t *restrict_attr,void*(*start_rtn ...
- 如何设置div的宽度为100%-xx px?
如何设置div的宽度为100%-xx px? 参见如下帖子:http://stackoverflow.com/questions/15183069/div-width-100-10px-relativ ...
- MUI - 上拉刷新/下拉加载
新闻信息列表必备的功能,支持Table,Ul等列表. 以下是DIV版本,在安卓端或者ios端必须使用双webview模式,传送门:http://dev.dcloud.net.cn/mui/pulldo ...
- free一个无效指针
1. 错误描述: 刚才写了一个删除单链表的结点函数, 参数是 指向链表的指针和链表中指定删除的结点的指针. 当我free这个待删除的结点, 结果报错. 2. 为什么会报错? 我查了查MSDN, ...
- iOS frame从导航栏下面开始
iOS7.0 之后,页面布局默认延伸到了手机界面的边缘;导航栏背景成透明颜色. 解决fram从导航栏下面开始方法: 第一种: 将导航栏改成不透明即可 if( ([[[UIDevice currentD ...
- LaTex 文本排版
一.对齐段落 \\ or \newline 另起一行,而不是另起一段 \\* 在强制断行后,还禁止分页 \newpage 另起一页 \linebreak[n] \nolinebreak[n] \pag ...
- String-自定义功能
<script> /* *发现js中的String对象有限,想要对字符串操作的其他功能. *比如:去除字符串两端的空格.这时只能自.定义 */ //去除字符串两端的空格 function ...
- php解析一个url
$url = "http://shopnc.localhost/shop/index.php?act=goods&op=index&goods_id=25220"; ...
- asp.net identity 2.2.0 在WebForm下的角色启用和基本使用(二)
管理用户功能: 界面部分: <%@ Page Title="" Language="C#" MasterPageFile="~/Site.mas ...