Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

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

x &= ~0x0f;

ぼちぼちソフト作家。 テニス・オセロ・ゲーム類が趣味の年齢不詳のおじさんです。vi と C++が好き。 お持ち帰りのお仕事募集中でござるぞ。 迷走中・・・
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away