Raised This Month: $ Target: $400
 0% 

Help with a bit-field


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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