C++ 位集庫 - to_ullong() 函式



描述

C++ 函式std::bitset::to_ullong() 將位集轉換為無符號長長整數。

宣告

以下是來自 std::bitset 標頭檔案的 std::bitset::to_ullong() 函式的宣告。

C++98

unsigned long long to_ullong() const;

引數

返回值

將位集作為無符號長長整數返回。

異常

如果丟擲異常,位集不會發生變化。

示例

以下示例演示了 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
bitset.htm
廣告

© . All rights reserved.