[Numpy-discussion] should rint return int?

Chris Barker chris.barker at noaa.gov
Mon Apr 28 13:49:21 EDT 2014

On Mon, Apr 28, 2014 at 10:36 AM, Neal Becker <ndbecker2 at gmail.com> wrote:

> I notice rint returns float.  Shouldn't it return int?

AFAICT, rint() is the same as round(), except with slightly different rules
for the "halfway" case. So returning a float makes sense, as round() and
ceil() and floor() all do.

( though I've always thought those should return inegers, too... )

By the way, what IS the difference between rint and round?

In [37]: for val in [-2.5, -3.5, 2.5, 3.5]:
   ....:     assert np.rint(val) == np.round(val)

In [38]:



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.go <Chris.Barker at noaa.gov>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140428/5bf9212d/attachment.html>

More information about the NumPy-Discussion mailing list