[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison

Johann Hibschman johann at physics.berkeley.edu
Fri Oct 27 16:18:22 EDT 2000


Darren New writes:

> Alex Martelli wrote:
>> mod (ideally) for truncating division
>> remainder (currently existing but spelled %)

> Better than spelling it with the *wrong* name. Why spell "remainder" as
> "mod", which implies it is "modulo" when it isn't? Personally, I've never
> found a need for "remainder" and often found a need for "modulo" and had to
> fix it every time those two differ.

What's 'remainder', if not the same as 'modulo'?  I understand both of
those terms to mean "least positive residue".  Unfortunately python
doesn't do this for negative divisors, which is a bit of a glitch.

"r = a % m" should preferrably be in the range from 0 < r < |m|,
right?  This won't work with python's default division, where
everything rounds to negative infinity.  Fix that, and everything
works.

By the way, what is the logic behind "-1/-3 = 0"?  That just seems
broken.  -1/3 = -1, so we should have -1/-3 = 1.  If division were
defined that way, we could simply let % give the least positive
residue, and everyone would be happy.

Is there any situation in which you would want -1/-3 = 0?

--J

-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list