View Single Post
happy_2012
Senior Member
Join Date: Aug 2012
Old 08-25-2018 , 03:31   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
Reply With Quote #82

Quote:
Originally Posted by Bugsy View Post
PHP Code:
BitCountiVal )
{
    
iVal iVal - ((iVal >> 1) & 0x55555555);                    
    
iVal = (iVal 0x33333333) + ((iVal >> 2) & 0x33333333);     
    return ((
iVal + (iVal >> 4) & 0xF0F0F0F) * 0x1010101) >> 24

This page has a lot of interesting bit hacks.
Does this count players with multiple bitsums at the same time?

e.g. BitCount( bitsum_is_zombie | bitsum_is_alive )
happy_2012 is offline