作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
我是编程新手。最近我遇到了一个问题,我必须将数字的特定位设为 0。
例如:
我有一个数字p
p = 73
binary = 1001001
现在我想把第 4 位设为 0,即 1000001(2) = 65(10)
我是通过以下方式做到的:
int p = 73;
int pos = 1<<3; // 4th bit
int max_bit = (1<<31) - 1; // making all bit to 1
int mask = pos ^ max_bit; // making 4th bit to 0 except others
p = p & mask; // changing 4th bit of p to 0
cout<<p<<endl;
有更好的方法吗?
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 4 年前。
正如您在 this travis.yml 中看到的那样文件,我的代码依赖于一些第三方库,我在构建项目之前将它们安装在远程系统上。 Travis 每次推送提交时都会下载并构建这些库,这可以避免吗?我的意
我是一名优秀的程序员,十分优秀!