When I tried to use dynamic_bitset::to_ulong() to convert a binary to decimal number, a weird thing happened. My original number is 1010101,which is 85 in decimal. However, the following code prints 55 instead. I can’t figure it out. My compiler is MingW.
boost::dynamic_bitset<> db(10,BOOST_BINARY(1010101));
cout<<db.to_ulong()<<endl; //should be 85.
85 in decimal is 0x55 in hexadecimal. Check your iostream flags.