Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ITH3

Clearing bits

This topic is 5607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say I have something like this:
      
#define SOLID_TOP    0x00000001 
#define SOLID_BOTTOM 0x00000002 
#define SOLID_LEFT   0x00000004 
#define SOLID_RIGHT  0x00000008

int properties = SOLID_TOP | SOLID_BOTTOM;
      
I want to be able to clear SOLID_TOP from properties and still have SOLID_BOTTOM left in it. How do I do this? Thanks for any help. [edited by - ITH3 on March 16, 2003 6:27:33 PM] [edited by - ITH3 on March 16, 2003 6:28:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
myFlag &= ~FLAG_I_DONT_WANT;

EDIT: Thought I should give some reasons. If FLAG_I_DONT_WANT has a bit set, when you inverse it, everything BUT that bit is now set. When you AND it with myFlag, everything is one, except the bit you don't want, which is 0. That will eliminate your bit from the flag.

[edited by - Zipster on March 16, 2003 6:41:56 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!