Advertisement Jump to content
Sign in to follow this  

Remove bits from a DWORD...

This topic is 4978 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

I have a flag variable which sets various bits in a DWORD to indicate certain states. I have a method called RemoveFlags() which looks a bit like this:
void ScreenEntityBase::RemoveFlags(DWORD removeFlags)
	Flags = Flags ^ removeFlags;

Which doesn't seem to work. 1. Am I just being stupid? 2. Does anybody know why this doesn't have the desired effect of removing the given bits? Thanks, Mark

Share this post

Link to post
Share on other sites
Not really. Where does flags go afterwards? Is it a member variable? How is this called and with what values? You did not do any operator overloading?

Also not that this will, as a side effect, turn on any bits that should be removed but are not turned on in the flag. Check the XOR table:

0 0 0
0 1 1 <-- Flag bit is off; Remove bit is on; Result is on
1 0 1
1 1 0



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!