标题: 如何用bis,bic(位清除,位设置)实现或,异或 [打印本页] 作者: lpzgbd 时间: 2010-12-05 20:36 标题: 如何用bis,bic(位清除,位设置)实现或,异或 现在有两个函数bis,bic。bis的功能是位设置,bic的功能是位清除。申明为:
int bis(int x ,int m)
int bic(int x ,int m)
参数m为掩码,对于bis,就是在m为1的每个位置,修改x的对应位为1,并返回修改后的值。同理,对bic,修改x的对应位为0后返回。
呵呵,这个我暂时还没有想到。{:3_189:} ,坐等高手解决阿作者: Etrnls 时间: 2010-12-06 00:34
允许
bool_not写成bic(0x很多f, x)不
可以的话就可以
x and y = not(not(x) or not(y))
x xor y = (x and not(y)) or (not(x) and y)作者: pagx 时间: 2010-12-06 00:36
bis(bic(x, y), bic(y, x))作者: jerryz920 时间: 2010-12-06 00:46
or + not = everything作者: Etrnls 时间: 2010-12-06 00:49
or + not = everything
jerryz920 发表于 2010-12-06 00:46
但是not挺麻烦的,还是你楼上的简单,bic其实就是x and not(y)
先去凑not结果反而更复杂了……作者: jerryz920 时间: 2010-12-06 00:56 回复 8#Etrnls