测试了一下,要进行高精度计算需要用 字符串 表示数字
然后定义 prec 的值,示例代码如下,你想用多高精度都行
------
from decimal import *
getcontext().prec = 180
x = "4.26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000032"
y = "2.13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021"
print(Decimal(x))
print(Decimal(y))
z = Decimal(x) + (Decimal(y))
print(z)
【 在 feng321 (sfdf) 的大作中提到: 】
: a=2.1
: b=3.2
: print(a+b)
: ...................
--
修改:Spirituel FROM 111.36.207.*
FROM 111.36.207.*