What is (x & 1) and (x >>= 1)?
问题 I am trying to do assignment: "Find the number of bits in an unsigned integer data type without using the sizeof() function." And my design is to convert the integer to bits and then to count them. For ex: 10 is 1010 and 5 is 101 Converting integer to a bit representation shows something like this: do { Vec.push_back( x & 1 ) } while ( x >>= 1 ); I don't want to just copy paste stuff. When I use F-10 I see what (x & 1) is doing but I don't know it is name or how it does its job(compare