For the purpose of bit-packing quality control tests, each position is a test. As an example, if tests 1, 2, and 6 for a measurement have failed, then the qc flag value would be binary *100011* with test 1 being the first position on the right, test 2 being the second position from the right, and test 6 being the 6th position from the right.

It's easy to create a binary mask and use a logical AND to determine if the tests you are interested in have tripped. Let's say we are interested in knowing if tests 1,2,3 and 5 have been tripped:

test position = 987654321 test mask = 000010111 AND sample qc_flag = 000100011 --------- result = 000000011

So, at a glance you can see that applying our mask (looking for tests 1,2,3 and 5) to the example qc_flag results in finding that tests 1 and 2 have failed. A simple thing to do is to see if the result of the AND operation results in anything non-zero. If so, then we discard the data sample, since the operation tells us one of the tests we are concerned about has been tripped.