What is the meaning of "&^" operator?

huangapple go评论77阅读模式
英文:

What is the meaning of "&^" operator?

问题

我是一名Golang的新手,对于"&^"运算符感到困惑。

根据规范中的解释,"&^"表示按位清除(AND NOT)。根据我的理解,它的意思是:x &^ y == x & (^y)。

我的理解正确吗?谢谢!

英文:

I am a newbie of golang, and confused with the "&^" operator.

From the <a href="http://golang.org/ref/spec">spec</a>, the explanation of "&^" is: bit clear (AND NOT). Per my understanding, it means: x &^ y == x & (^y).

Is my understanding right? Thanks!

答案1

得分: 6

你的理解是正确的。
你可以将其视为“位运算符”
并且规则如下:

1 &^ 1 = 0
1 &^ 0 = 1
0 &^ 0 = 0
0 &^ 1 = 0

就像 x & yx ^ yx | y 一样。

英文:

Your'understanding is right.
You can make it as a "bit operator"
And the rules:

1 &amp;^ 1 = 0
1 &amp;^ 0 = 1
0 &amp;^ 0 = 0
0 &amp;^ 1 = 0

Just like x &amp; y, x ^ y, x | y.

huangapple
  • 本文由 发表于 2013年12月31日 13:32:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/20852293.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定