ginac库任意精度运算

2020-10-13  本文已影响0人  一路向后

1.程序源码

#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main()
{
        //定义分数
        numeric a = 3;
        numeric b = 0;

        //修改精度
        Digits = 100;

        b = sqrt(a);

        //打印输出结果
        cout << b.evalf() << endl;

        return 0;
}

2.编译源码

$ g++ -o example example.c -lginac -lcln -I/usr/local/include -L/usr/local/lib64

3.运行结果

./example
1.7320508075688772935274463415058723669428052538103806280558069794519330169088000370811461867572485756756261414154067
上一篇 下一篇

猜你喜欢

热点阅读