[Numpy-discussion] numpy.floor() is supposed to return an int, but returns a float
Charles R Harris
charlesr.harris at gmail.com
Sun Apr 9 22:12:02 CDT 2006
On 4/9/06, Tim Hochberg <tim.hochberg at cox.net> wrote:
> Let me just add that, since this seems to cause confusion, it would be
> appropriate to amend the docstring tobe explicit that this always
> returns an integral floating point value. If someone wants to suggest
> wording, I can figure out where to put it. One possibility is:
> "y = floor(x) elementwise largest integer <= x; note that the result
> is a floating point value"
> "y = floor(x) elementwise largest integral float <= x"
How about, "for each item in x returns the largest integral float <= item."
I too once found the C definition of the floor function annoying, but I got
used to it. Sorta like getting used to a broken leg. The main problem is
that the result can't be used as an index without conversion to a "real"
integer. Integers aren't members of the reals (or rationals): apart from +/-
1, integers don't have inverses. There happens to be an injective ring
homomorphism of the integers into the reals, but that is not the same thing.
On the other hand, ints are generally not big enough to hold all of the
integral doubles, so as a practical matter the originators made the best
choice. Things do get a bit weird for large floats because above a certain
threshold floats are already integral values.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion