Comment on PEP-0238

Terry Reedy tjreedy at home.com
Mon Jul 2 17:06:33 EDT 2001


"Paul Prescod" <paulp at ActiveState.com> wrote in message
news:mailman.994084684.19932.python-list at python.org...
...
> That is simply not true. Most people do not expect these four
> expressions to yield different results:
>
> 1.0/3.0
> 1/3
> 1.0/3
> 1/3.0

'People' could mean anything from 'CLP-reading Pythoneers' to 'all humans'.
The result of a survey of expections would depend on the the precise
population surveyed, the precise wording of the question, the manner in
which the question is given, whether and what clarification is given to
those who say they do not understand the question, and the treatment of "I
don't know", "I'm not sure", and "I was never very good at math" type
answers, which I believe (without direct data)would predominate in some
'general' populations.

> If you were taught this in school, it must be "new math".

Presuming that 'this' is the possibility that 1/3 might have a different
correct result than 1.0/3 and that calling that idea "new math" is meant as
a put down, this snide comment is doubly incorrect.  1) I learned long
division (by hand, no calculators) of whole numbers (counts) in about 1955,
before there was a 'new math'.  We learned to give answers as quotient 'r'
remainder.  I presume that this was standard practice in the US then, if
not now. 2) Indivisible units are not divisible.  Example: a school has 4
first grade classrooms and 82 new first graders.  If we split the students
evenly among the classrooms, how many in each?  The correct answer is 20
with 2 left over, not 20.5.  A student sliced in two is not a student or
even two halves of a student, but two chunks of dying flesh, an ancient
wisdom credited to Solomon.

Framing the integer division question in the context of the very special
case of reciprocals is an unfair tactic.  One indivisible unit divided into
multiple parts is so very obviously 0 r 1 that we would normally not write
1/n to ask such a question.  (Example: 1 BDFL divided among 3 simultaneous
computer conferences on different continents is how many BDFLs at each?
.33333333?  I'm sure BDFL hopes not.)  So it is usually reasonable (in this
special case only), upon seeing an explicitly written 1/n, to assume that
the 1 is a divisible 1.0, especially since '1/n', unlike 1+n, 1-n, or 1*n,
is ambiguous to human readers in that it can be read as representing the
result of performing the operation.  However, in a general case such as
82/4, the expression is more obviously a problem to be solved (which is how
the interpreter sees it) rather than an answer in itself and the assumption
of divisibility may well be disasterously wrong.

So I propose the following question to be asked of 'people':

"Do you expect the following two questions to have the same numerical
answer?
A. If a string 82 centimeters long is cut into 4 equal pieces, how long is
each?
B. If 82 students are divided evenly among 4 classrooms, how many will be
in each?"

Or, if proponents of change insist on using potential division of a unit:

"On one of Solomon's open court days, citizens of his realm bring him two
similar disputes.  Should he settle each with the same mathematical
procedure?
A. Two hungry boys each claim, with equal evidence, a delicious peach pie.
B. Two day-old mothers each clain, with equal evidence, a newborn baby as
their own.  (The other baby died at birth, and neither DNA testing or
definitive evidence is available)."

With these wordings of the question, I doubt even a majority would
definitely give the wrong answer "Yes, the same".

Underlying these formulations of the survey question is the observation
that most arithmetic is done to answer questions about the 'real' world by
using numbers to represent or model quantities of things in the world.
When so, each number has an at least implicit unit attached.  In this
context, the fundamental question is whether the unit is divisible (or is
allowed to be) or not.  If not, one uses (in Python) an integer (or long).
If the units are divisible, one should tell readers and the interpreter by
using divisible numbers (floats, complex) to model them, either from the
start (by adding '.0') or at least at the point of division (by converting
with float()).  The suffix '.0' says "Yes, this number is currently a whole
number (whether by design or accident) but it represents something that is
splittable and which we may well want to split into fractions."  Requiring
that people think about divisibility in choosing a number representation is
no more burdensome (and I think less so) than requiring them to think about
mutability in choosing a tuple versus list sequence representation.

Terry J. Reedy





More information about the Python-list mailing list