Based on the position of nibble (upper or lower), a bit shif operation is performed. If the upper nibble is preffered, a right shift operation by 4 bits is done and then an and operation with (0x0F) to return the upper nibble value. In case of lower nibble, a simple AND operation with 0x0F will return the lower nibble.