import decimal
# set the precision to double that of float64.. or whatever you want.
decimal.setcontext(decimal.Context(prec=34))
def foo(x, y, z)
x,y,z = [decimal.Decimal(v) for v in (x,y,z)]
a = x + y * z
return a # you forgot this line in the original code.
可以声明变量,但可以尝试将其强制为预期类型
对我来说,显而易见的答案是十进制,除非函数需要非常快。在
如果需要常规的64位浮点,只需将返回值转换为: 回油浮子(a)
相关问题 更多 >
编程相关推荐