Q: Feature Wish: "%" Extension

John Roth johnroth at ameritech.net
Tue Nov 6 17:37:50 EST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.1005007807.32030.python-list at python.org...
> [John Roth]
> > The basic sign rules for multiplication are so clear that I don't
> > really need to repeat them here. If division is the inverse of
> > multiplication, then the sign rules follow directly. Any definition
> > of division which does not do that isn't an inverse of
multiplication,
> > but some other operation masquerading under the same name.
>
> Are you serious?  In a world where 3/4 == 0, how long could any
programmer
> survive believing that integer division and multiplcation are
"inverses"?
> The antecedent is dead on arrival.

Integer division is not an inverse of integer multiplication, therefore
the proposed counterexample fails.

> > This might be a much more useful operation in practice, but
> > it is confusing to someone who expects the system to behave
> > the way he was taught in grammer school.
>
> I can enumerate a hundred ways in which computer arithmetic confuses
> beginners, and I bet you could too.  It even confuses beginners that,
say,
> 4.00 - 1.00 gets displayed as 3 or 3. instead of 3.00.

Well, yes, but that isn't (pure) mathematics. It's a particular
implementation.

> > In other words, (-i)/j should  -(i/j).
>
> Newbies "know" too that if i < 0 and j > 0, then i/j < 0 (isn't that
one of
> the "basic sign rules" you're defending?).  But-- oops! --*that* one
happens
> to be true of floor division, but not of truncating division.  Integer
> division (whether truncating, flooring, rounding, or what have you) is
an
> information-losing process, and the loss of information kills
identities
> without prejudice.

See my comment above. I'm not refering to integer division.
We've been around that circuit too many times to make
it really appealing to do so again.

I'm refering to either rational (in the future) or real division,
in both of which division is supposed to be the exact inverse
of multiplication.

John Roth





More information about the Python-list mailing list