我遇到np.round,np.around的問題,它沒有正確舍入。我不能包含的代碼,因爲當我做手工設置的值(而不是用我的數據),返回工作,但這裏是輸出:在Python中舍入遊標的問題
In [177]: a
Out[177]: 0.0099999998
In [178]: np.round(a,2)
Out[178]: 0.0099999998
In [179]: np.round(a,1)
Out[179]: 0.0
我缺少什麼? a的dtype是float32,我需要改變它嗎?
這裏。閱讀所有[that](http://perso.ens-lyon.fr/jean-michel.muller/goldberg.pdf) – JBernardo
您的預期產出是什麼?也許看看python的[decimal](http://docs.python.org/library/decimal.html)類型,如果你真的必須有一個「確切」的值。 – jozzas
'np'是Numpy? –