C + + Std::bitset

Source: Internet
Author: User

http//blog.csdn.net/qll125596718/article/details/6901935


#include <iostream>
#include <stdint.h>
#include <bitset>
using namespace Std;


int main () {
for (uint64_t i=0; i<64; i++) {
Bitset<64> BS;
uint64_t j = (uint64_t) 1 << i;
Bs.set (i);
cout << i << ":" << bs << "," << Bs.to_ulong () << Endl;
}
return 0;
}

0:0000000000000000000000000000000000000000000000000000000000000001,1
1:0000000000000000000000000000000000000000000000000000000000000010,2
2:0000000000000000000000000000000000000000000000000000000000000100,4
3:0000000000000000000000000000000000000000000000000000000000001000,8
4:0000000000000000000000000000000000000000000000000000000000010000,16
5:0000000000000000000000000000000000000000000000000000000000100000,32
6:0000000000000000000000000000000000000000000000000000000001000000,64
7:0000000000000000000000000000000000000000000000000000000010000000,128
8:0000000000000000000000000000000000000000000000000000000100000000,256
9:0000000000000000000000000000000000000000000000000000001000000000,512
10:0000000000000000000000000000000000000000000000000000010000000000,1024
11:0000000000000000000000000000000000000000000000000000100000000000,2048
12:0000000000000000000000000000000000000000000000000001000000000000,4096
13:0000000000000000000000000000000000000000000000000010000000000000,8192
14:0000000000000000000000000000000000000000000000000100000000000000,16384
15:0000000000000000000000000000000000000000000000001000000000000000,32768
16:0000000000000000000000000000000000000000000000010000000000000000,65536
17:0000000000000000000000000000000000000000000000100000000000000000,131072
18:0000000000000000000000000000000000000000000001000000000000000000,262144
19:0000000000000000000000000000000000000000000010000000000000000000,524288
20:0000000000000000000000000000000000000000000100000000000000000000,1048576
21:0000000000000000000000000000000000000000001000000000000000000000,2097152
22:0000000000000000000000000000000000000000010000000000000000000000,4194304
23:0000000000000000000000000000000000000000100000000000000000000000,8388608
24:0000000000000000000000000000000000000001000000000000000000000000,16777216
25:0000000000000000000000000000000000000010000000000000000000000000,33554432
26:0000000000000000000000000000000000000100000000000000000000000000,67108864
27:0000000000000000000000000000000000001000000000000000000000000000,134217728
28:0000000000000000000000000000000000010000000000000000000000000000,268435456
29:0000000000000000000000000000000000100000000000000000000000000000,536870912
30:0000000000000000000000000000000001000000000000000000000000000000,1073741824
31:0000000000000000000000000000000010000000000000000000000000000000,2147483648
32:0000000000000000000000000000000100000000000000000000000000000000,4294967296
33:0000000000000000000000000000001000000000000000000000000000000000,8589934592
34:0000000000000000000000000000010000000000000000000000000000000000,17179869184
35:0000000000000000000000000000100000000000000000000000000000000000,34359738368
36:0000000000000000000000000001000000000000000000000000000000000000,68719476736
37:0000000000000000000000000010000000000000000000000000000000000000,137438953472
38:0000000000000000000000000100000000000000000000000000000000000000,274877906944
39:0000000000000000000000001000000000000000000000000000000000000000,549755813888
40:0000000000000000000000010000000000000000000000000000000000000000,1099511627776
41:0000000000000000000000100000000000000000000000000000000000000000,2199023255552
42:0000000000000000000001000000000000000000000000000000000000000000,4398046511104
43:0000000000000000000010000000000000000000000000000000000000000000,8796093022208
44:0000000000000000000100000000000000000000000000000000000000000000,17592186044416
45:0000000000000000001000000000000000000000000000000000000000000000,35184372088832
46:0000000000000000010000000000000000000000000000000000000000000000,70368744177664
47:0000000000000000100000000000000000000000000000000000000000000000,140737488355328
48:0000000000000001000000000000000000000000000000000000000000000000,281474976710656
49:0000000000000010000000000000000000000000000000000000000000000000,562949953421312
50:0000000000000100000000000000000000000000000000000000000000000000,1125899906842624
51:0000000000001000000000000000000000000000000000000000000000000000,2251799813685248
52:0000000000010000000000000000000000000000000000000000000000000000,4503599627370496
53:0000000000100000000000000000000000000000000000000000000000000000,9007199254740992
54:0000000001000000000000000000000000000000000000000000000000000000,18014398509481984
55:0000000010000000000000000000000000000000000000000000000000000000,36028797018963968
56:0000000100000000000000000000000000000000000000000000000000000000,72057594037927936
57:0000001000000000000000000000000000000000000000000000000000000000,144115188075855872
58:0000010000000000000000000000000000000000000000000000000000000000,288230376151711744
59:0000100000000000000000000000000000000000000000000000000000000000,576460752303423488
60:0001000000000000000000000000000000000000000000000000000000000000,1152921504606846976
61:0010000000000000000000000000000000000000000000000000000000000000,2305843009213693952
62:0100000000000000000000000000000000000000000000000000000000000000,4611686018427387904
63:1000000000000000000000000000000000000000000000000000000000000000,9223372036854775808

C + + Std::bitset

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.