0
我有四个方面的类型分别由二进制字节表示:位运算来比较值
sector one: 0000 0001
sector two: 0000 0010
sector three: 0000 0100
sector four: 0000 1000
现在,我得到了它返回一个整数值的功能,我需要检查这个值是否是一个部门。什么是检查它的最有效的方法?我的意思是按位操作。
int val = func();
//check if val is one of the sector