I am working with Landsat-8 C1-Level 2 imagery and I need the information that NASA provides in the pixel_qa file. The information about the content of the pixel is given by turning on a certain bit, plus some eventual other bits to indicate the confidence of the class (e.g. clouds are indicated turning on the 5th bit, bits 6-7 give the confidence value for the cloud, pixels 8-9 the confidence for the cirrus). This means that there are several combinations of values that can indicate the same class. I know r.mapcalc has some bit-wise operators, but I haven't found what I'm looking for: is there a way to check if a specific bit (e.g. the 6th out of 16) is on or off?
Is there any more practical way to retrieve the information I need?