2010年12月12日 星期日

Population Count of a Uint32

When studying Android audio system, I saw a interest function code in google’s AndioSystem class:

uint32_t AudioSystem::popCount(uint32_t u)

{

    u = ((u&0x55555555) + ((u>>1)&0x55555555));

    u = ((u&0x33333333) + ((u>>2)&0x33333333));

    u = ((u&0x0f0f0f0f) + ((u>>4)&0x0f0f0f0f));

    u = ((u&0x00ff00ff) + ((u>>8)&0x00ff00ff));

    u = ( u&0x0000ffff) + (u>>16);

    return u;

}

Honestly, I cannot understand how this code come from. Fortunately, the code leave a reference link for us: http://www.df/lth/se/~john_e/gems/gem002d.html.

And telling the trust again, for me, it’s still hard to understand after reading the reference algorithm. So, I decide to make a node, and just copy the code when I need it ~ 吐舌頭.

2010年12月5日 星期日

會無好會

今天在參與了一個案子的 Kick-Off Meeting,會議過程亂七八糟,會議內容五花八門,會議目標模糊不清。真的是讓我上了一堂震撼教育,原來公司大頭們開會是這樣子開的喔!?