提高浮点数精度 [英] increasing float-point numbers accuracy

查看:103
本文介绍了提高浮点数精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将默认浮点数精度切换为另一个(也许是自定义)精度?我需要这个,因为我做了一些计算,我发现我应该提高默认浮点精度.

How to switch default floating point numbers accuracy to another, maybe custom? I need this, cause I do some calculations and I see that I should increase default float point accuracy.

推荐答案

我最近不得不处理此问题,并且 mpmath 非常完美.它是纯B许可下的纯python.

I've recently had to deal with this problem and the mpmath was perfect. It is pure python, under a BSD license.

Mpmath是用于多精度浮点算术的纯Python库.它提供了广泛的先验函数集,无限的指数大小,复数,区间算术,数值积分和微分,求根,线性代数等.几乎任何计算都可以以10位或1000位精度进行同样好的计算,并且在许多情况下,mpmath实现了渐近快速算法,可以很好地扩展以用于极高精度的工作

Mpmath is a pure-Python library for multiprecision floating-point arithmetic. It provides an extensive set of transcendental functions, unlimited exponent sizes, complex numbers, interval arithmetic, numerical integration and differentiation, root-finding, linear algebra, and much more. Almost any calculation can be performed just as well at 10-digit or 1000-digit precision, and in many cases mpmath implements asymptotically fast algorithms that scale well for extremely high precision work

它并不太慢,它可以利用 gmpy 库(如果已安装)(a C-coded Python extension modules that support fast multiple-precision arithmetic).

It is not too much slower, and it can leverage the gmpy library if installed (a C-coded Python extension modules that support fast multiple-precision arithmetic).

这篇关于提高浮点数精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆