Sdílet prostřednictvím


bitset::to_ulong

Převede objekt bitset na celé číslo, které vytvoří posloupnost bitů obsažených, pokud je použit k inicializaci bitset.

unsigned long to_ulong( ) const;

Vrácená hodnota

Celé číslo, které by generovat bity bitset při inicializaci bitset.

Poznámky

Použitím členské funkce vrátí celé číslo, které se nachází v posloupnosti bitů obsažených v bitset má stejnou posloupnost číslic 1 a 0.

Vyvolá členskou funkci overflow_error Pokud žádné bit v posloupnosti bitů má bit hodnotu, která nemůže být reprezentován jako hodnotu typu unsigned long*.*

Příklad

// bitset_to_ulong.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>

int main( )
{
   using namespace std;

   bitset<5> b1 ( 7 );

   cout << "The ordered set of bits in the bitset<5> b1( 7 )"
        << "\n that was generated by the number 7 is: ( "
        << b1 << " )" << endl;

   unsigned long int i;
   i = b1.to_ulong( );
   cout << "The integer returned from the bitset b1,"
        << "\n by the member function to_long( ), that"
        << "\n generated the bits as a base two number is: "
        << i << "." << endl;
}
  

Požadavky

Záhlaví:<bitset>

Obor názvů: std

Viz také

Referenční dokumentace

bitset – třída