[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison
Alex Martelli
aleaxit at yahoo.com
Tue Oct 24 06:34:37 EDT 2000
"Charles Boncelet" <boncelet at udel.edu> wrote in message
news:39F4A4DE.9202540A at udel.edu...
[snip]
> > > > Guido thinks that 2/3 returning 0 was a design mistake,
[snip]
> I often want 2/3 to equal 0, but then again I learned FORTRAN years ago.
>
> My point is that if 2/3 = 0.667, then special syntax is needed for those
> applications that want 2/3=0. The current syntax is very simple, even
> if slightly confusing to a complete newby.
Note that a prominent beginners' language, Pascal, avoids this
specific design mistake: 2/3 is 0.6666667, and you use 2 div 3
if you want truncating-division. 2/3 returns a floating-point
number also in another language that may well be the only one
a beginner knows, Visual Basic in all of its forms. Therefore,
it is quite possible that people who have programmed before get
very surprised by the truncation -- not everybody is learning
Fortran, C or Java as their first language...:-).
I'd rather have 2/3 return a _rational_ number 2/3, as in
Scheme -- another reasonably popular beginners' language.
But that requires having rationals built-in, I guess...:-).
Alex
More information about the Python-list
mailing list