Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试使用 dynamic_bitset::to_ulong() 将二进制数转换为十进制数时,发生了一件奇怪的事情。我原来的号码是 1010101,十进制是 85。但是,下面的代码会打印 55。我想不通。我的编译器是 MingW。
boost::dynamic_bitset<> db(10,BOOST_BINARY(1010101)); cout<<db.to_ulong()<<endl; //should be 85.
十进制的 85 是十六进制的 0x55。检查您的 iostream 标志。
#include <iostream> #include <iomanip> std::cout << std::dec << n << std::endl; // formats as decimal