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

Darren New dnew at san.rr.com
Fri Oct 27 18:21:18 EDT 2000


Johann Hibschman wrote:
> What's 'remainder', if not the same as 'modulo'?  

The problem is with negatives. X mod 7 is between 0 and 6 (inclusive) for
all X.

-3 mod 7 != 3 and -3 mod 7 != -3.

-3 mod 7 = 4. -1 mod 7 = 6.

That's the definition of mod, and that's the semantics I find useful.
Note: I don't think there *is* a definition for mod that handles a negative
number as the second argument.

Now, if you're not going to define it that way, then you shouldn't call it
"mod". Call it "remainder". Call it "divrem" and not "divmod". :-)

> "r = a % m" should preferrably be in the range from 0 < r < |m|,
> right?

Well, 0 <= r < |m| I would guess.

-- 
Darren New / Senior MTS & Free Radical / Invisible Worlds Inc.
San Diego, CA, USA (PST).  Cryptokeys on demand.
The tragedy of the commons applies to monitizing eyeballs, too.



More information about the Python-list mailing list