C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ to_ullong()

C++ to_ullong()函数

C++ to_ullong()用于将 的内容转换为无符号的long long整数。它会返回一个无符号long long,其整数值与 的位设置相同。

语法

unsigned long long to_ullong(); 

参数

不带任何参数。

返回值

它返回一个整数值与 对象具有相同的位表示形式。

示例1

#include <iostream>
#include <bitset>
using namespace std;
int main()
{
  bitset<4> b;
  b.set();
  cout << b << " as an integer is : " << b.to_ullong();
   return 0;
} 
输出:
1111 as an integer is : 15 

示例2

#include <iostream>
#include <bitset>
using namespace std;
int main()
{
  bitset<6> b(string("001100"));
  b.set();
  int a=b.to_ullong();
  cout << b << " as an integer is : " << a;
   return 0;
} 
输出:
111111 as an integer is : 63 
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4