按位AND等 [英] Bitwise AND etc

查看:69
本文介绍了按位AND等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在论坛中搜索按位运算符,那么就会有很多

的问题和非常好的答案,这些问题关于这些运算符的作用以及我们需要它们的原因。

所以,看了所有这些,我接近了K& R 2.9! ...但是

不长:-(


引用:

按位AND运算符&经常用于屏蔽一些位;

例如,

n = n& 0177;

除了低位7以外都设置为零n。


结束报价;


有人可能只是用一个例子证明这一点吗?(我有

试图理解0177的事实,我相信''10110001''。

然而这并没有让我走得太远。

提前谢谢。

解决方案

mdh写道:

如果在论坛中搜索按位运算符有很多
问题和非常好的答案,关于这些运营商做什么以及我们为什么需要它们的问题。
所以,看了所有这些,我接近K& R 2.9 !! ...但是
不久:-(

引用:
按位AND运算符&是通常用于遮盖一些位;例如,
n = n& 0177;
除n的低位7位外都设置为零。

结束报价;

有人可能只是用一个例子证明这一点吗? (我已经试着理解0177的事实,我相信''10110001''。
然而这并没有让我走得太远。
提前致谢。


0177是一个八进制(基数为8)的数字,所以它是二进制的01111111。


-

Ian Collins 。


" mdh"写道:

按位AND运算符&经常被用来屏蔽掉一些位;
例如,
n = n& 0177;
除n的低位7位外都设置为零。

结束报价; 然而这还没有让我走得很远。




它是八进制所以它意味着1 111 111.




Ian Collins写道:

0177是八进制(基数8)数字,所以它是二进制的01111111。



oops ...


嗯,我很高兴我问!好的......现在有道理了。

谢谢。


If one searches the forum for bitwise operators there are numerous
questions and very good answers to the perenial question about what
these operators do and why we need them.
So, having looked at all these, I approached K&R 2.9 headily!! ...but
not for long :-(

Quote:
The bitwise AND operator & is often used to mask off some set of bits;
for example,
n=n & 0177;
sets to zero all but the low-order 7 bits of n.

End Quote;

Could someone perhaps just demonstrate this with an example? (I have
tried to make sense of the fact that 0177 is, I believe ''10110001''.
However this has not gotten me very far.
Thanks in advance.

解决方案

mdh wrote:

If one searches the forum for bitwise operators there are numerous
questions and very good answers to the perenial question about what
these operators do and why we need them.
So, having looked at all these, I approached K&R 2.9 headily!! ...but
not for long :-(

Quote:
The bitwise AND operator & is often used to mask off some set of bits;
for example,
n=n & 0177;
sets to zero all but the low-order 7 bits of n.

End Quote;

Could someone perhaps just demonstrate this with an example? (I have
tried to make sense of the fact that 0177 is, I believe ''10110001''.
However this has not gotten me very far.
Thanks in advance.


0177 is an octal (base 8) number, so it is 01111111 in binary.

--
Ian Collins.


"mdh" writes:

The bitwise AND operator & is often used to mask off some set of bits;
for example,
n=n & 0177;
sets to zero all but the low-order 7 bits of n.

End Quote;

Could someone perhaps just demonstrate this with an example? (I have
tried to make sense of the fact that 0177 is, I believe ''10110001''.
However this has not gotten me very far.



It''s octal so it means 1 111 111.



Ian Collins wrote:

0177 is an octal (base 8) number, so it is 01111111 in binary.


oops...

Well, I am glad I asked!! Ok...now it makes sense.
thank you.


这篇关于按位AND等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆