#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; }
时间: 2024-11-06 21:55:22