c++取出int的每一位bit


是在qt中做的,所以用了qlist,可根据需要改成 stl 的 list

void GetStatus(unsigned int status, QList<bool>& listStatus)
{
    bool current = false;
    for (int i = 0; i < 32; i++) {
        if(status & (1 << i)){
            current = true;
        }
        else {
            current = false;
        }
        listStatus.push_back(current);
        
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM