[NumPy-Tickets] [NumPy] #1661: rint(0.5) = 0 ? why?

NumPy Trac numpy-tickets@scipy....
Wed Nov 3 18:29:21 CDT 2010


#1661: rint(0.5) = 0 ? why?
--------------------+-------------------------------------------------------
 Reporter:  fegdri  |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:  2.0.0   
Component:  Other   |     Version:          
 Keywords:          |  
--------------------+-------------------------------------------------------
 What is wrong with rint, round, around functions?

 {{{
 >>> a = np.array([-2.5, -1.5, -1.4, -0.5, 0.5, 1.5, 2.5, 3.4])
 >>> np.rint(a)
 array([-2., -2., -1., -0.,  0.,  2.,  2.,  3.])
 >>> np.around(a)
 array([-2., -2., -1., -0.,  0.,  2.,  2.,  3.])
 >>> np.round(a)
 array([-2., -2., -1., -0.,  0.,  2.,  2.,  3.])
 >>> np.round_(a)
 array([-2., -2., -1., -0.,  0.,  2.,  2.,  3.])
 }}}

 How can it be that -2 is the nearest number to both -2.5 and -1.5?

 I was expecting to see
 {{{
 array([-3., -2., -1., -1., 1., 2., 3., 3.])
 }}}

 ---

 Version: 1.5.1rc1 (win32, python2.7)

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1661>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list