Cpp-standard-library-cpp-bitset-to-ullong

提供:Dev Guides
移動先:案内検索

C ++ビットセットライブラリ-to_ullong()関数

説明

C ++関数* std
bitset :: to_ullong()*は、ビットセットを符号なしlong longに変換します。

宣言

以下は、std
bitsetヘッダーからのstd :: bitset :: to_ullong()関数の宣言です。

C 98

unsigned long long to_ullong() const;

パラメーター

None

戻り値

戻り値は、符号なしの長い長い数としてビットセット。

例外

例外がスローされた場合、ビットセットの変更はありません。

次の例は、std
bitset :: to_ullong()関数の使用方法を示しています。
#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;
}

上記のプログラムをコンパイルして実行すると、次の結果が生成されます-

Decimal representation of 1010 = 10