C++ converting binary(64 bits) to decimal -
i using string contain 64 bits binary.
string abinary; abinary = "100011111011101100000101101110000100111000011100100100110101100";
initially tried this..
stringstream ss; ss << bitset<64>(abinary).to_ulong(); buffer = ss.str(); cout << buffer << endl;
its work binary, 1 doesn't work. how can convert above 64 bits binary contain in string container decimal of string container too.
it's overflowing, because to_ulong()
32-bits.
c++-11 introduces function to_ullong()
, want. if don't have that, can try splitting string two, 2 32-bit numbers, convert 64-bit, shift , add.
Comments
Post a Comment