按位-如何检查二进制数是否包含另一个? [英] Bitwise - How can I check if a binary number contains another?
本文介绍了按位-如何检查二进制数是否包含另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
A = 110000000 - 384 Blue+Red
B = 011000010 - 194 Green+Black+Red
A & B = C = 010000000 - 128 Red
如何检查B是否包含A中的所有位,也许还包含其他位?在上述情况下,我想得到"false".
How can I check if B contains all the bits in A and perhaps others? In the case above I would like to get "false".
我正在使用XCode& Objective-c,但据我所知应该无关紧要
I'm using XCode & objective-c but that shouldn't matter as far as I know
推荐答案
如果A& B(即交集)等于A:
B contains A if A & B (ie, the intersection) is equal to A:
(a & b) == a
类似于...
a ⊆ b ↔ (a ∩ b) = a
从集合论开始.
这篇关于按位-如何检查二进制数是否包含另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文