2 4 8 16 32 64 128
public static boolean isAContainsB(int a, int b) {
return a == 0 || (a & b) == b;
}
System.out.println(BitOperationUtil.isAContainsB(24, 8));
System.out.println(BitOperationUtil.isAContainsB(24, 16));
System.out.println(BitOperationUtil.isAContainsB(24, 3));
System.out.println(BitOperationUtil.isAContainsB(10, 2));
System.out.println(BitOperationUtil.isAContainsB(10, 8));
System.out.println(BitOperationUtil.isAContainsB(10, 4));
例如 14 与 2 4 8 返回为true