Given 2 binary strings
of the same length (e.g.
), is it possible to check if all set bits in
is also set in
using bitwise operations? In the above example,
b = 110000
has two set bits in position 1 and 2 (from left to right), and those bits are also set in
a = 111000
I can compare two strings character-wise but that would be too slow. I know I can turn the strings into number with something like
but I don't know the bitwise operations to use to achieve the task.