You can use boost multiprecision library to store integer of arbitary size and then process it to produce binary output.
Following is code which use library, convert to hex using std::hex conversion and then reads hex stream and output binary stream. I have overloaded >> for bitset to read big decimal number into bitstream. << outputs correct binary output as expected. you can use any size bitset (in multiple of 4), it should work. Of coarse, error checking has to be done so that it does not cross bitset size. Probably you can start with this version.
#include <boost/multiprecision/cpp_int.hpp>
#include<bitset>
#include<iostream>
using namespace std;
template<int N>
istream& operator >> (istream& in, bitset<N>& b)
{
using namespace boost::multiprecision;
cpp_int bigNumber;
stringstream ss;
in >> bigNumber;
ss << std::hex << bigNumber;
b.reset();
int i = 0;
string s = ss.str();
for (auto& iter = s.rbegin(); iter != s.rend(); iter++)
{
switch (toupper(*iter))
{
case '0':
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 0; i++;
break;
case '1':
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 0; i++;
break;
case '2':
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 0; i++;
break;
case '3':
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 0; i++;
break;
case '4':
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 0; i++;
break;
case '5':
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 0; i++;
break;
case '6':
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 0; i++;
break;
case '7':
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 0; i++;
break;
case '8':
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 1; i++;
break;
case '9':
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 1; i++;
break;
case 'A':
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 1; i++;
break;
case 'B':
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 1; i++;
break;
case 'C':
b[i] = 0; i++;
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 1; i++;
break;
case 'D':
b[i] = 1; i++;
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 1; i++;
break;
case 'E':
b[i] = 0; i++;
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 1; i++;
break;
case 'F':
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 1; i++;
b[i] = 1; i++;
break;
}
}
return in;
}
int main()
{
std::bitset<80> b;
cin >> b;
cout << b << endl;
system("pause");
return 0;
}
output of program:
9999999999999
00000000000000000000000000000000000010010001100001001110011100101001111111111111
Press any key to continue . . .