C++ Bitset Library - to_ullong() Function



Description

The C++ function std::bitset::to_ullong() convert bitset to unsigned long long.

Declaration

Following is the declaration for std::bitset::to_ullong() function form std::bitset header.

C++98

 unsigned long long to_ullong() const; 

Parameters

None

Return value

Returns bitset as unsigned long long number.

Exceptions

No change in bitset if exception is thrown.

Example

The following example shows the usage of std::bitset::to_ullong() function.

 #include <iostream> #include <bitset> #include <typeinfo> using namespace std; int main(void) { bitset<4> b("1010");; auto result = b.to_ullong(); cout << "Decimal representation of " << b << " = " << result << endl; return 0; } 

Let us compile and run the above program, this will produce the following result −

 Decimal representation of 1010 = 10 
bitset.htm
Advertisements