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

Charles Boncelet boncelet at udel.edu
Tue Oct 24 11:27:54 EDT 2000


Alex Martelli wrote:

> "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 certainly concede 2/3=0 may be startling to a newcomer, but
feel that its as important or more so for a language to appeal
to experienced programmers.  E.g., Fortran, C, Java are
survivors and lots of serious code are written in these languages.
Pascal is a dying (dead?) language.  Visual Basic is a survivor,
but not because 2/3 = 0.667 :-)

>
>
> 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...:-).

Having never learned Scheme, I didn't know this.  A built-in
rational class is an interesting notion.

    Charlie


--
Charles Boncelet                              302-831-8008
Dept of Electrical and Computer Engineering   302-831-4316 (fax)
University of Delaware                        boncelet at eecis.udel.edu
http://www.eecis.udel.edu/~boncelet/






More information about the Python-list mailing list