[英]How to use the C++ max function with boost 128 bit integer
If I have the following code:如果我有以下代码:
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision
int main()
{
int128_t a = Func_a()
int128_t b = Func_b()
std::cout << std::max(a, b) << std::endl;
return 0;
}
And if I compile using g++ on Ubuntu, I get the following error:如果我在 Ubuntu 上使用 g++ 编译,我会收到以下错误:
error: cannot convert 'const boost::multiprecision::number >' to 'int64 {aka long long int}' in assignment错误:无法在赋值中将“const boost::multiprecision::number >”转换为“int64 {aka long long int}”
What is the proper way to compare two int128_t numbers to see which one is greater?比较两个 int128_t 数字以查看哪个更大的正确方法是什么?
EDIT: I am using std::max.编辑:我正在使用 std::max。
Your code (except for missing semicolons) compiles and runs without error.您的代码(除了缺少分号)编译和运行没有错误。
However, according to your compiler message, I'm suspecting that in但是,根据您的编译器消息,我怀疑在
int128_t a = Func_a(); // are you really sure it is int128_t?
the left-hand side is not a boost::multiprecision::int128_t
, since the compiler says it is a int64.左侧不是
boost::multiprecision::int128_t
,因为编译器说它是 int64。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.