Getting one bit from a bitsum
Code:
new bitsum = (1<<0)|(1<<1)|(1<<2)|(1<<4); |
Re: Getting one bit from a bitsum
PHP Code:
|
Re: Getting one bit from a bitsum
Ya I was thinking maybe I could do something such as:
Code:
new randbit; |
Re: Getting one bit from a bitsum
Quote:
PHP Code:
PHP Code:
|
Re: Getting one bit from a bitsum
I'm guessing I have my terminology wrong, I'll show more example code:
Code:
#define P_FLAG_A (1<<0) /* flag "a" */Code:
new bitsum = P_FLAG_A|P_FLAG_B|P_FLAG_D;It looks like to me that with your way randbit would be filled with 0,1,2, or 3. But I want (1<<0),(1<<1),(1<<2), or (1<<3). Correct me if I'm wrong. |
Re: Getting one bit from a bitsum
new randbit = 1<<random(4)
Is this what you want ? |
Re: Getting one bit from a bitsum
Quote:
If you want your way, just do: PHP Code:
PHP Code:
|
Re: Getting one bit from a bitsum
@Bugsy: I think you've misunderstood what Emp' wants. He wants to get a random bit and store it into a variable. He doesn't want to know if a certain bit is in a bitsum. He wants to get a random bit for that bitsum.
Therefore, checking if the random bit exists in the bitsum would be useless, as he can just limit the randomization to the number of bits in the bitsum. So jim_yang is most correct. |
Re: Getting one bit from a bitsum
I think you are wrong, he wants :
There is an existing variable that contains some bits, he want to pick up random bits from this variable. |
Re: Getting one bit from a bitsum
Quote:
|
| All times are GMT -4. The time now is 08:56. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.