为什么在google源码中往往能看到使用 二进制数据
来源:互联网 发布:js导入导出excel数据 编辑:程序博客网 时间:2024/04/24 19:33
http://blog.csdn.net/jjwwmlp456/article/details/38737721
http://blog.csdn.net/jjwwmlp456/article/details/38737721
http://blog.csdn.net/jjwwmlp456/article/details/38737721
http://blog.csdn.net/jjwwmlp456/article/details/38737721http://blog.csdn.net/jjwwmlp456/article/details/38737721
为什么在google源码中往往能看到使用 二进制数据
分类: Android2014-08-21 22:42 33人阅读 评论(0) 收藏 举报
二进制
- public class Demo {
- static int a = 0x1;
- static int b = 0x2;
- static int c = 0x4;
- static int d = 0x8;
- static int e = 0x10;
- static int f = 0x20;
- static int g = 0x40;
- static int h = 0x80;
- static int i = 0x100;
- static int j = 0x200;
- public static void main(String[] args) {
- System.out.println(a);
- System.out.println(b);
- System.out.println(c);
- System.out.println(d);
- System.out.println(e);
- System.out.println(f);
- System.out.println(g);
- System.out.println(h);
- System.out.println(i);
- System.out.println(j);
- }
- }
输出结果
- 1
- 2
- 4
- 8
- 16
- 32
- 64
- 128
- 256
- 512
上面使用16进制0x的形式,定义了一些二进制的数据,发现他们非常有规律,1 2 4 8 .... 进位时后面加0就是下一个二进制数。书写简单
它们在二进制的表示为1,10,100,1000,10000.... 类似这样只有一位有效位,其他位全为0
再来看下面
- System.out.println(h | j);
- System.out.println((h | j) & h);//与比或的 优先级高
- System.out.println((h | j) & j);
- System.out.println(h & j);
输出结果
- 640
- 128
- 512
- 0
当a不等于b时,按位与(&)时,结果直接就为0
当a=b时,不管按位与还是按位或 那结果还是a
综上,所以源码中很多就如此应用了这一效果。 一般有一个 0x0的空、无的状态, 再有 1 2 4 8 ... 这样的二进制数的状态
用按位或: 可以将 多个状态累加 类似 flag1 | flag2 | flag3 ,得到的结果在二进制中的表示可能为101001
用按位与: 可以将 内部的一个记录自身当前状态的变量 按位与 一个定义的状态值 类似 mCurFlag & FLAG1
当结果不为0时或者说等于FLAG1时, 表示含有FLAG1这个状态
0 0
- 为什么在google源码中往往能看到使用 二进制数据
- 为什么在google源码中往往能看到使用 二进制数据
- 为什么人往往只能看到自己愿意相信的真相
- 从5组数据中所能看到的
- 在ICCAVR中通过使用库函数来避免直接看到敏感算法源码
- ios中qq在进入后台的情况下为什么还能接收到数据
- 何时能在我的网站上看到展示 Google 广告
- 为什么Google能一直领先?
- 【工具】在这里你能看到intellj(idea)的源码
- 成功往往在失败中酝酿
- 计算机为什么用二进制存储数据?即为什么是0101010,为什么不用其他进制?既然计算机是二进制,为什么又衍生出来一八进制、十六进制干什么,八进制和十六进制在计算机中有什么用呢?
- 为什么RTP往往是使用UDP,而不是使用TCP封装
- 为什么RTP往往是使用UDP,而不是使用TCP封装
- 为什么RTP往往是使用UDP,而不是使用TCP封装
- python在twisted中实现二进制数据
- 计算机为什么使用二进制?
- 上传的文件(图片)在Eclipse中能看到,在浏览器中看不到的解决办法
- 数据库中使用Blob处理二进制数据
- 我的Android笔记(十一)——使用Preference保存设置
- OpenCV 中结构体IplImage 成员width widthStep使用注意事项
- CRC校验实现原理以及程序实现研究
- 5.反射例子
- JSP学习 —— 开篇:JSP,servlet容器,Tomcat,servlet容器之间的关系
- 为什么在google源码中往往能看到使用 二进制数据
- 6. java基础学习总结1
- 2014北京网络预选赛1006(贪心)HDU5037
- Jsp学习——servlet详解
- Directx 9.0/9.0c 在vs2008 里面的环境配置
- 抛弃C程序设计中的谬误与恶习(3)
- 关于经典开源框架STRUTS2的使用
- 15、NDK_ROOT not defined. Please define NDK_ROOT in your environment解决方案
- 7. java基础学习总结2