我们在数据类型方面遇到了很多问题。 我在c ++中的数据类型存在很大问题。 我必须处理100位数字。 我一直试图使用mpfr real,但编译器总是崩溃。
#include <iostream>
#include <gmp.h>
#include <mpfr.h>
mpfr::real Modulo(mpfr::mpreal number);
int main()
{
mpfr::mpreal test, number;
number = 3.14159;
mpfr::mpreal::getPrecision(500)
mpfr::mpreal a = "-1";
mpfr::mpreal prime = "57896044618658097711785492504343953926634992332820282019728792003956564819949";
mpfr::mpreal d = "-121665/121666";
test=Modulo(number);
}
mpfr::mpreal:: Modulo(mpfr::mpreal number)
{
extern mpfr::mpreal a , d, prime;
a = d;
std::cout << prime;
return number;
}
这只是某种评价。 系统无法找到mpfr /&#34的声明; mpfr不是类型&#34; 已安装库。
错误讯息:
/home/tamwyn/evaluate/main.cpp|5|error: ‘mpfr’ does not name a type|
/home/tamwyn/evaluate/main.cpp||In function ‘int main()’:|
/home/tamwyn/evaluate/main.cpp|6|error: ‘mpfr’ has not been declared|
/home/tamwyn/evaluate/main.cpp|6|error: expected ‘;’ before ‘test’|
/home/tamwyn/evaluate/main.cpp|7|error: ‘number’ was not declared in this scope|
/home/tamwyn/evaluate/main.cpp|8|error: ‘mpfr’ has not been declared|
/home/tamwyn/evaluate/main.cpp|9|error: expected ‘;’ before ‘mpfr’|
/home/tamwyn/evaluate/main.cpp|10|error: ‘mpfr’ has not been declared|
/home/tamwyn/evaluate/main.cpp|10|error: expected ‘;’ before ‘prime’|
/home/tamwyn/evaluate/main.cpp|11|error: ‘mpfr’ has not been declared|
/home/tamwyn/evaluate/main.cpp|11|error: expected ‘;’ before ‘d’|
/home/tamwyn/evaluate/main.cpp|13|error: ‘test’ was not declared in this scope|
/home/tamwyn/evaluate/main.cpp|13|error: ‘Modulo’ was not declared in this scope|
/home/tamwyn/evaluate/main.cpp|17|error: ‘mpfr’ does not name a type|
||=== Build finished: 13 errors, 0 warnings ===|
real.hpp:
#include <iostream>
#include <gmp.h>
#include "real.hpp"
mpfr::real test, number;
number = 3.14159;
mpfr::real::getPrecision(500)
mpfr::real a = "-1";
mpfr::real prime = "57896044618658097711785492504343953926634992332820282019728792003956564819949";
mpfr::real d = "-121665/121666";
与其他示例中的结构相同,但现在使用另一个声明并且出现更多错误:
Compiling: main.cpp
/home/tamwyn/evaluate/main.cpp:5:1: error: invalid use of template-name ‘mpfr::real’ without an argument list
/home/tamwyn/evaluate/main.cpp: In function ‘int main()’:
/home/tamwyn/evaluate/main.cpp:9:14: error: missing template arguments before ‘test’
/home/tamwyn/evaluate/main.cpp:9:14: error: expected ‘;’ before ‘test’
/home/tamwyn/evaluate/main.cpp:10:3: error: ‘number’ was not declared in this scope
/home/tamwyn/evaluate/main.cpp:11:9: error: ‘template<long int _prec, mpfr_rnd_t _rnd> class mpfr::real’ used without template parameters
/home/tamwyn/evaluate/main.cpp:12:3: error: expected ‘;’ before ‘mpfr’
/home/tamwyn/evaluate/main.cpp:13:15: error: missing template arguments before ‘prime’
/home/tamwyn/evaluate/main.cpp:13:15: error: expected ‘;’ before ‘prime’
/home/tamwyn/evaluate/main.cpp:14:15: error: missing template arguments before ‘d’
/home/tamwyn/evaluate/main.cpp:14:15: error: expected ‘;’ before ‘d’
/home/tamwyn/evaluate/main.cpp:16:3: error: ‘test’ was not declared in this scope
/home/tamwyn/evaluate/main.cpp:16:21: error: ‘Modulo’ was not declared in this scope
/home/tamwyn/evaluate/main.cpp: At global scope:
/home/tamwyn/evaluate/main.cpp:20:1: error: invalid use of template-name ‘mpfr::real’ without an argument list
对于这样的数字和更长的数字,您有什么类型的建议吗? 我为mpfr找到了几个,但总是有同样的问题。