我想我没有得到什么。
该类cpp_int是否boost::multiprecision应该保存与想要的一样大的整数?假设我想存储以下大得离谱的整数。我该怎么做呢?
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
cpp_int n = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
Run Code Online (Sandbox Code Playgroud)
以下代码返回
error: integer literal is too large to be represented in any integer type
正如文档中详细说明的,您需要使用字符串来构造:
cpp_int n{"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"};
Run Code Online (Sandbox Code Playgroud)