試過109221975 * 123222821乘法在Python 2.7的提示兩種不同的方式不同的結果在Python上VS浮動
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 109221975*123222821
13458639874691475L
>>> 109221975*123222821.0
1.3458639874691476e+16
>>> int(109221975.0*123222821.0)
13458639874691476L
>>> 109221975*123222821 == int(109221975.0*123222821.0)
False
>>>
相同的數字作爲整數相乘什麼,我懷疑這裏有一些精度不一致是造成這樣的問題,是否有可能推測何時會出現這種不一致?
http://docs.python.org/2/tutorial/floatingpoint。 html – dm03514
感嘆。另一天,另一個FP混淆。請參閱[什麼每臺計算機科學家應該知道關於浮點運算(http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) – dawg
應該有一個警告你後,如果之前float在您的問題文本中的任何位置首先閱讀該文章。 – IanAuld