[Numpy-discussion] how to round to int (I mean 5.2 to 5 not 5.0)
Tue Mar 6 22:53:54 CST 2007
Sebastian Haase wrote:
> why does
> return a float ?
Partly because that's what the underlying C standard library function does and
what the Python function round() does. The reason they do that is because the
range of integers supported by the double precision floating point type is
larger than the range of integers supported by C ints.
In : numpy.round(1e16)
In : numpy.round(1e16).astype(int)
> I need something that I can use as indices for another array. Do I
> have to (implicitly) create a temporary array and use:
> N.round(a).astype(N.int) ?
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion