def GetBit(x, oneBasedBitNumber):
    """Returns the value of the specified bit (1 to 32)."""
    if oneBasedBitNumber < 1 or oneBasedBitNumber > 32:
        raise ValueError('invalid bit number')
    return (int(x) >> (oneBasedBitNumber-1)) & 1