LoginSignup
8
5

More than 5 years have passed since last update.

ビットクリア演算子(&^)

Last updated at Posted at 2016-07-31

Go にはビットクリア演算子(&^)というのがある。

x y x &^ y
0 0 0
0 1 0
1 0 1
1 1 0

結果に対し x と y が対称ではないしなんだこれ?と思ったけど、大した話ではなく x の 0 にしたいビットを y で指定してるだけですね。例えば x の下位 2 ビットをクリアするのであれば y の下位 2 ビットを 1 にする。

x 0101
y 0011
x &^ y 0100

ってことですね。

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5