我正在使用 boost 库来处理大数字。
#include <iostream>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/number.hpp>
namespace mp=boost::multiprecision;
using namespace std;
int main()
{
typedef mp::number<mp::backends::cpp_bin_float<2000> > cpp_bin_float227;
cpp_bin_float227 b = 998;
std::cout << std::numeric_limits<cpp_bin_float227>::digits << std::endl;
cout<<std::setprecision(std::numeric_limits<cpp_bin_float227>::max_digits10)<<pow(b,9999)<<endl;
}
但是我在编译时遇到了这个错误:
fatal error: boost/multiprecision/cpp_bin_float.hpp: No such file or directory
#include <boost/multiprecision/cpp_bin_float.hpp>
如果我使用 cpp_dec_float 而不是 cpp_bin_float,它工作正常。 为什么找不到库以及如何修复它?
(我在 Ubuntu 中使用 c++11 编译器)
解决方案: 问题是在 answe 中,即旧版本的 boost 库。 支持 cpp_bin_float 的最低版本是 1.58
删除当前版本:
apt-get --purge remove libboost-dev libboost-doc
后来我安装了1.63版本(不是最新的1.64)
http://www.linuxfromscratch.org/blfs/view/cvs/general/boost.html
最佳答案
那个版本的 boost 没有 cpp_bin_float
。它也很老了。
现场观看:
- boost 1.54 https://wandbox.org/permlink/7MQy5HR90GB0GbVt
- boost 1.55 https://wandbox.org/permlink/nPOH5kDRCq1PUXWl
- boost 1.56 https://wandbox.org/permlink/IhClSKBx0k0pSVUe好的!
关于c++ - 在 boost 库之间找不到 cpp_bin_float,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45212589/