Reading integer

70 views Asked by At

Here's the code I'm trying to change

string binary = "000000100001000100010000000100000"
bitset<32> set(binary);
cout << hex << set.to_ulong() << endl;

The code shows 2112010 but I want it to show 02112010.

2

There are 2 answers

0
rerun On

that is the same number you can format it with the 0 by using format specifiers if you need to retain the zero you need to store it as a string,

1
NPE On
std::cout << std::setfill('0') << std::setw(5) << i << std::endl;