How to check if none of the bits are set in a bitset with C++

1 Answer

0 votes
#include <bits/stdc++.h> 
  
using namespace std; 
    
int main() 
{ 
    bitset<4> bs(string("0000")); 
     
    if (bs.none()) 
        cout << "yes";
    else
        cout << "no";
     
    return 0; 
} 
  
  
  
/*
run:
  
yes
  
*/

 



answered Dec 7, 2019 by avibootz

Related questions

1 answer 202 views
1 answer 167 views
1 answer 194 views
194 views asked Jul 17, 2018 by avibootz
1 answer 227 views
227 views asked Jul 16, 2018 by avibootz
2 answers 208 views
1 answer 273 views
...