Skip to content

Latest commit

 

History

History
47 lines (26 loc) · 1.42 KB

CppStdBitset.md

File metadata and controls

47 lines (26 loc) · 1.42 KB

 

 

 

 

 

 

std::bitset is a container for bits.

 


#include <bitset> #include <iostream> int main() {   const int sz = 8;   std::bitset<sz> x;   for (int i=0; i!=sz; ++i)   {     std::cout << x << '\t' << x.to_ulong() << '\n';     x[i] = true;   }   std::cout << x << '\t' << x.to_ulong() << '\n'; }

 

Screen output:

 


00000000 0 00000001 1 00000011 3 00000111 7 00001111 15 00011111 31 00111111 63 01111111 127 11111111 255