Raised This Month: $ Target: $400
 0% 

Help with a bit-field


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kiske
Veteran Member
Join Date: May 2009
Old 08-14-2011 , 08:29   Help with a bit-field
Reply With Quote #1

Hi.

It's my first time using bits.
I wanted to know how to do this:
PHP Code:
#define set_user_bit(%1, %2)     (%2 |= (1 << (%1 & 31)))
#define clear_user_bit(%1, %2)     (%2 &= ~(1 << (%1 & 31)))
#define has_user_bit(%1, %2)     (%2 & (1<< (%1 & 31)))

if(has_user_bit(idg_data[MD])) set_user_bit(idg_data[MD]);
else 
clear_user_bit(idg_data[MD]); 
but a simpler way like this:
PHP Code:
g_data[id] = !g_data[id]; 

Another question,
PHP Code:
g_data[id] = var; 
I can do this bit ?

Thanks in advance.

Last edited by Kiske; 08-14-2011 at 08:34.
Kiske is offline
Send a message via Skype™ to Kiske
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2011 , 08:59   Re: Help with a bit-field
Reply With Quote #2

- you can use the simpler way
- no you can't, bit can only handle bools (0 or 1 vars).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Kiske
Veteran Member
Join Date: May 2009
Old 08-14-2011 , 10:07   Re: Help with a bit-field
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
- you can use the simpler way
- no you can't, bit can only handle bools (0 or 1 vars).
Ok, thanks
Kiske is offline
Send a message via Skype™ to Kiske
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode