自分用のミニライブラリ#1

(1) popcnt64 (from bla/kp0024.c)

int popcnt64(unsigned long long b)
{
    b -= b >> 1 & 0x5555555555555555ULL;
    b = (b & 0x3333333333333333ULL) + (b >> 2 & 0x3333333333333333ULL);
    b = (b + (b >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
    return (b * 0x0101010101010101ULL) >> 56;
}

(2) popcnt32

int popcnt32(unsigned int b)
{
    b -= b >> 1 & 0x55555555U;
    b = (b & 0x33333333U) + (b >> 2 & 0x33333333U);
    b = (b + (b >> 4)) & 0x0f0f0f0fU;
    return (b * 0x01010101U) >> 24;
}

トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS