View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-19-2009 , 15:47   Re: [INFO] Bitsums and Operators
Reply With Quote #6

Quote:
Originally Posted by joaquimandrade View Post
Bugsy you can also do this: (i don't know how to put a % in a macro)

1 << value % 32
Yes, either way works. Your method using modulus will make the 0 bitshift occur at 32 instead of 1 like my -1 method.

PHP Code:
#define AddFlag(%1,%2)        ( %1 |= ( 1 << (%2 % 32) ) )
#define RemoveFlag(%1,%2)     ( %1 &= ~( 1 << (%2 % 32) ) )
#define CheckFlag(%1,%2)      ( %1 & ( 1 << (%2 % 32) ) ) 
__________________
Bugsy is offline