Thursday, 12 September 2013

Clear bit if another is set

Clear bit if another is set

Is there's a similar to:
if((bitmap & BIT_WATER) && (bitmap & BIT_FIRE)) bitmap &= ~BIT_FIRE
or
if(bitmap & BIT_WATER) bitmap &= ~BIT_FIRE
In a single statement using only bitwise operations, removing the need of
a comparation (if)?

No comments:

Post a Comment