Original Post
Ok, here's something that's been on my bugging me since last night, I have a function that receives flags(ex: draw( x, y, BLAH | BLAH2 ); ) to do is get the number of bits that are set in the flag. Here's an example of how the flags are defined.
const int BLAH = 128;
const int BLAH2 = 64;
const int BLAH3 = 32;
const int BLAH4 = 16;
const int BLAH5 = 8;
const int BLAH6 = 4;
const int BLAH7 = 2;
const int BLAH8 = 1;
So lets say I pass BLAH | BLAH2, I know that I have 2 bits set but lets say that I don't know the number that's going to be passed and I want to count how many bits are set, is there a way that I can do it???
"And that's the bottom line cause I said so!"
** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM **
Cyberdrek
Resist Windows XP's Invasive Production Activation Technology!
"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
Edited by - cyberdrek on December 17, 2001 9:13:03 PM