java位运算判断多状态

将int值(8位)提取每一位

    private void parseInt(int forParse)
    {
        status[0] = (forParse & 1) > 0 ? true : false;
        status[1] = ((forParse & 2) >> 1) > 0 ? true : false;
        status[2] = ((forParse & 4) >> 2) > 0 ? true : false;
        status[3] = ((forParse & 8) >> 3) > 0 ? true : false;
        status[4] = ((forParse & 16) >> 4) > 0 ? true : false;
        status[5] = ((forParse & 32) >> 5) > 0 ? true : false;
    }

results matching ""

    No results matching ""