public member function
unsigned long to_ulong ( ) const;
Convert to unsigned long integer
Returns an unsigned long
with the integer value that has the same bits set as the bitset.
Integer value with the same bits set as the bitset.
If the bitset
is too long to be represented as an unsigned long
, an overflow_error
exception is thrown.
using namespace std;
int main ()
bitset<4> mybits; // mybits: 0000
mybits.set(); // mybits: 1111
cout << mybits << " as an integer is: " << mybits.to_ulong() << endl;
1111 as an integer is: 15
- Convert to string (public member function)
- Construct bitset (public member function)