我正在构建一个 C++ 程序来验证一个数学猜想,最多可进行 1000 亿次迭代。为了测试这么高的数字,我不能使用 a C++ int
,所以我使用NTL
库,使用类型ZZ
作为我的数字类型。
我的算法如下所示:
ZZ generateNthSeq(ZZ n)
{
return floor(n*sqrt(2));
}
我有两个要导入的库:
#include <cmath>
#include <NTL/ZZ.h>
但显然这无法编译,因为我收到错误:
$ g++ deepness*.cpp
deepness.cpp: In function ‘NTL::ZZ generateNthSeq(NTL::ZZ)’:
deepness.cpp:41: error: no matching function for call to ‘floor(NTL::ZZ)’
/usr/include/bits/mathcalls.h:185: note: candidates are: double floor(double)
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:262: note: long double std::floor(long double)
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:258: note: float std::floor(float)
说明地板数学运算不能接受 ZZ 类类型。但我需要数字相当大。如何在使用 NTL 库的同时完成我想要做的事情,即地板功能?