带boost的大整数:太大,无法用任何整数类型表示
big ints with boost : too large to be represented in any integer type
我想我没有得到什么。
boost::multiprecision
中的类cpp_int
是否应该包含所需大小的整数?假设我想存储下面这个大得离谱的整数。我该怎么做?
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
cpp_int n = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
以下代码返回
error: integer literal is too large to be represented in any integer type
如文档中所述,您需要使用字符串进行构造:
cpp_int n{"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"};
请参阅https://www.boost.org/doc/libs/1_74_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html
相关文章:
- C++模板函数,用于比较任何无符号整数和有符号整数
- 如何检测除整数以外的任何内容是否传递给我的类构造函数?
- 如何在不给它任何类型(如整数)的情况下定义某物?
- 整数文本太大,无法用任何整数类型表示--C++
- boost::任何带有结构体和无符号整数
- 是否有任何内置函数可以检查给定的两个数字在给定整数数组中的顺序是否相同?
- 如何对 int 变量应用验证,使其仅接受整数数据,并且在任何其他数据的情况下不会出错?
- 你能在任何独立于架构的低级语言中获得更小的整数吗?
- 任何可以在单个 CPU 指令中在 0 和 1 之间翻转位/整数/布尔值的可能代码
- 为什么当用户输入除整数之外的任何内容时,我的程序会无限循环输出?C++
- 在比较两个字符串之前(整数)之前,将字符串转换为整数有任何好处
- 在C 中弹出任何元素后,会自动调整数组大小
- wchar_t保证与任何整数类型不同
- 如何检查输入是否是没有任何其他字符的有效整数
- 除 "6" 作为最右边数字的整数输入外,任何整数输入都可以使用,但任何数字(如 ...6.导致分段错误,为什么?
- 对于每个标量“T”,是否有任何保证存在相同大小的整数
- 如何仅将 16 位分配给二进制文件中的任何整数,而不是C++中的正常 32 位
- C++ 中任何基数中的整数文本
- 依靠任何数字类型(无符号、整数等)的隐式提升来加倍是否安全
- C++宏代码 - 显式整数(任何大小)转换为指针类型