C++中Boost库的cpp_dec_foat的最大值是多少

What is the max value of cpp_dec_float from Boost library in C++?

本文关键字:最大值 多少 foat dec Boost 库的 cpp C++      更新时间:2023-10-16

我想知道是什么值导致cpp_dec_foat溢出。我尝试了1000万的伽马函数,但仍然可以存储很大的数字。然而,1100万伽马无法存储。

您可以使用::max()函数来查找它可以存储的最大值(另请参阅有关多精度和numeric_limits的boost文档)。以cpp_dec_float_50:为例

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <iostream>
#include <limits>
using boost::multiprecision::cpp_dec_float_50;
int main() {
std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10);
std::cout << std::numeric_limits<cpp_dec_float_50>::max() << std::endl;
}

至于具体是什么导致溢出,你可能也会发现这个有趣的问题。