floating point division -- question

Steve Holden sholden at holdenweb.com
Wed Nov 27 15:55:40 EST 2002


"William Park" <opengeometry at yahoo.ca> wrote in message
news:as31ig$n7lq2$1 at ID-99293.news.dfncis.de...
> Gerhard H?ring <gerhard.haering at opus-gmbh.net> wrote:
> > William Park <opengeometry at yahoo.ca> wrote:
> >> Some time ago, there was thread discussing adding a floating point
division
> >> operator, like //.  Doing 'a//b' is certainly easier than doing
'a/float(b)',
> >> and it doesn't break any existing codes.  Has there been any interest
from
> >> the Gods of Python?
> >
> > Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> from __future__ import division
> >>>> 3 / 5
> > 0.59999999999999998
> >>>> 3 // 5
> > 0
> >
> > It's been there since the original Python 2.2 release. See
> > http://www.python.org/doc/current/whatsnew/node7.html for details.
>
> Thanks Gerhard.  Although I would've have switched the two operator, so
> that existing code doesn't change...
>

But there's simply no way you could do that. If you'd used "/" for integer
division then programs that used it with float operands would have broken.
Either way it's a change in semantics, and that's why Guido has decreed the
change will take so long.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list