Jump to content
  • Advertisement
Sign in to follow this  
mrmrcoleman

Remove bits from a DWORD...

This topic is 4882 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
Advertisement
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:

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


Greetz

Illco

Share this post


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

  • 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!