9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ビット演算 [3]:特定のビットを0にする

Last updated at Posted at 2014-09-07

変数の特定のビットの値を 0 にしたい場合は、そのビットのマスクの反転と算術論理積を行うといいぞ。

例えば、x の下位4ビットを0にしたい場合は以下のように記述する

x &= ~0x0f;

9
6
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
9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?