fork download
  1. #include <iostream>
  2. #include <bitset>
  3. using namespace std;
  4.  
  5. int main() {
  6. unsigned short short1 = 6;
  7. bitset<16> bitset1{short1}; // the bitset representation of 4
  8. cout << bitset1.count() << endl;
  9. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
2