位AND运算符 [英] Bitwise And Operator

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

问题描述

有人可以更简单地解释一下吗?

Can someone explain this in simpler terms?

170二进制重新presentation是 0000 0000 1010 1010 。 75二进制重新presentation是 0000 0000 0100 1011 。执行按位与运算这两个值生成二进制结果 0000 0000 0000 1010 ,这是十进制的10。

The binary representation of 170 is 0000 0000 1010 1010. The binary representation of 75 is 0000 0000 0100 1011. Performing the bitwise AND operation on these two values produces the binary result 0000 0000 0000 1010, which is decimal 10.

0000 0000 1010 1010
0000 0000 0100 1011
-------------------
0000 0000 0000 1010

这将使将点击我一次,我知道正在做什么。我有二进制文件的一个基本的了解,并知道一些把我的头顶部...像二进制psented 1重$ P $会 00000001 2是 00000010 3将 00000011 4将 00000100 和5将 00000101 和6将 00000110 。所以,我明白什么是对,当你每次起身数字去。

This will make will click for me once I know what is being done. I have a basic understanding of binaries and know a few off the top of my head... like 1 represented in binary would be 00000001 and 2 would be 00000010 and 3 would be 00000011 and 4 would be 00000100 and 5 would be 00000101 and 6 would be 00000110. So I understand what is going on when you got up a digit each time.

我也明白是怎么回事时,这条SQL开发人员在减去,但当她使用T-SQL code找到她的答案不缺少的东西....问候的是,在这个链接说明。

I also understand what is going on when this sql developer is subtracting, but not something is missing when she uses t-sql code to find her answers.... in regards to what is stated in this link.

http://sqlfool.com/2009/02/bitwise-operations/

推荐答案

看在你的榜样栏目个别二进制数字。如果在<青霉>两个输入的行的特定列的是有1,输出是1该列。否则为0。

Look at the individual binary digits in your example as columns. If there is a 1 in both input rows of a particular column, the output is 1 for that column. Otherwise it is 0.

AND操作符可以用于掩模的值。所以,如果你只是想一个数字的前四个低位,可以和它与15,像这样的:

The AND operator can be used to "mask" values. So if you just want the first four low-order bits of a number, you can AND it with 15, like this:

0010 1101 1110 1100
0000 0000 0000 1111
-------------------
0000 0000 0000 1100  <-- the value of the first four bits in the top number

这就是在你链接的SQL例子发生。

That's what is happening in the SQL example you linked.

freq_interval is one or more of the following:
1 = Sunday
2 = Monday
4 = Tuesday
8 = Wednesday
16 = Thursday
32 = Friday
64 = Saturday

对应位掩码:

0000 0001 = Sunday
0000 0010 = Monday
0000 0100 = Tuesday
0000 1000 = Wednesday
0001 0000 = Thursday
0010 0000 = Friday
0100 0000 = Saturday

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

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