首页 > 代码库 > 64位bitmap操作

64位bitmap操作

#include <stdio.h>

#define set_bit1(x,y)   (x|=(0x01L<<y))
#define set_bit0(x,y)   (x&=(~(0x01L<<y)))
#define get_bit(x,y)    (x&(0x01L<<y))

int main()
{
    int pos = 31;
    unsigned long bitmap = 0xffffffffffffffffL;
    set_bit0(bitmap, pos);
    printf("set0:%lu,get:%d\n", bitmap, get_bit(bitmap, pos)!=0?1:0);
    set_bit1(bitmap, pos);
    printf("set1:%lu,get:%d\n", bitmap, get_bit(bitmap, pos)!=0?1:0);
    return 0;
}

64位bitmap操作