擅长:python、mysql、java
<p>对我来说,显而易见的答案是十进制,除非函数需要非常快。在</p>
<pre><code>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.
</code></pre>
<p>如果需要常规的64位浮点,只需将返回值转换为:
回油浮子(a)</p>