std::bitset<N>::to_ulong (3) - Linux Manuals
std::bitset<N>::to_ulong: std::bitset<N>::to_ulong
Command to display std::bitset<N>::to_ulong
manual in Linux: $ man 3 std::bitset<N>::to_ulong
NAME
std::bitset<N>::to_ulong - std::bitset<N>::to_ulong
Synopsis
unsigned long to_ulong() const
Converts the contents of the bitset to an unsigned long integer.
The first bit of the bitset corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.
Parameters
(none)
Return value
the converted integer
Exceptions
throws std::overflow_error if the value can not be represented in unsigned long.
Example
// Run this code
#include <iostream>
#include <bitset>
int main()
{
for (unsigned long i = 0; i < 10; ++i) {
std::bitset<5> b(i);
std::bitset<5> b_inverted = ~b;
std::cout << i << '\t';
std::cout << b << '\t';
std::cout << b_inverted << '\t';
std::cout << b_inverted.to_ulong() << '\n';
}
}
Output:
0 00000 11111 31
1 00001 11110 30
2 00010 11101 29
3 00011 11100 28
4 00100 11011 27
5 00101 11010 26
6 00110 11001 25
7 00111 11000 24
8 01000 10111 23
9 01001 10110 22
See also
returns a string representation of the data
to_string (public member function)
to_ullong returns an unsigned long long integer representation of the data
(public member function)
(C++11)
Pages related to std::bitset<N>::to_ulong
- std::bitset<N>::to_ullong (3) - std::bitset<N>::to_ullong
- std::bitset<N>::to_string (3) - std::bitset<N>::to_string
- std::bitset<N>::test (3) - std::bitset<N>::test
- std::bitset<N>::all,std::bitset<N>::any,std::bitset<N>::none (3) - std::bitset<N>::all,std::bitset<N>::any,std::bitset<N>::none
- std::bitset<N>::bitset (3) - std::bitset<N>::bitset
- std::bitset<N>::count (3) - std::bitset<N>::count
- std::bitset<N>::flip (3) - std::bitset<N>::flip
- std::bitset<N>::operator&=,|=,^=,~ (3) - std::bitset<N>::operator&=,|=,^=,~
- std::bitset<N>::operator<<,<<=,>>,>>= (3) - std::bitset<N>::operator<<,<<=,>>,>>=
- std::bitset<N>::operator[] (3) - std::bitset<N>::operator[]
- std::bitset<N>::reference (3) - std::bitset<N>::reference
- std::bitset<N>::reset (3) - std::bitset<N>::reset
- std::bitset<N>::set (3) - std::bitset<N>::set
- std::bitset<N>::size (3) - std::bitset<N>::size
- std::bitset (3) - std::bitset