bitset::to_ulong

Convierte un objeto de bitset el entero que generaría la secuencia de bits contenido si se utiliza para inicializar el bitset.

unsigned long to_ulong( ) const;

Valor devuelto

Un entero que generaría los bits en un bitset si se utiliza en la inicialización de bitset.

Comentarios

Aplica la función miembro devolverá el entero que tiene la misma secuencia de los dígitos 1 y 0 que se encuentra en orden de los bits contenido en el bitset.

La función miembro produce overflow_error si los bits en la secuencia de bits tiene un valor de bit que no se puede representar como un valor de unsigned longescrito*.*

Ejemplo

// 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;
}
  

Requisitos

encabezado: <bitset>

espacio de nombres: std

Vea también

Referencia

bitset Class