how can you check an individual binary digit in c++

This question already has an answer here:

  • How do you set, clear, and toggle a single bit? 26 answers

  • To get bit n state (returns bit n as 0 or 1):

    (value>>n) & 1
    

    To set bit n state (flag is 0 or 1):

    value = (value & ~(1 << n)) | (flag << n)
    
    链接地址: http://www.djcxy.com/p/28802.html

    上一篇: 我怎样才能一点一点地分配给C中的一个整数?

    下一篇: 你怎么能在c ++中检查一个单独的二进制数字