首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::bitset::to_ullong

unsigned long long to_ullong() const

(since C++11)

将位集的内容转换为unsigned long long整数。

该位集的第一位对应于所述数字的最小有效位数,而所述最后一位对应于所述最有效位数。

参数

%280%29

返回值

转换的整数。

例外

std::overflow_error如果值不能表示为unsigned long long...

二次

代码语言:javascript
复制
#include <iostream>
#include <bitset>
#include <limits>
 
int main()
{
    std::bitset<std::numeric_limits<unsigned long long>::digits> b(
        0x123456789abcdef0LL
    );
 
    std::cout << b << "  " << std::hex << b.to_ullong() << '\n';
    b.flip();
    std::cout << b << "  " << b.to_ullong() << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
0001001000110100010101100111100010011010101111001101111011110000  123456789abcdef0
1110110111001011101010011000011101100101010000110010000100001111  edcba9876543210f

二次

另见

to_string

returns a string representation of the data (public member function)

to_ulong

returns an unsigned long integer representation of the data (public member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券