Math irregularity ... is this normal?
Dave Reed
dreed at capital.edu
Fri Jul 5 12:25:34 EDT 2002
Learning Python is based on python 1.5 which only prints0.4; as
someone else pointed out, somewhere in Python 2.x this behavior
changed:
$ python1.5
Python 1.5.2 (#1, Apr 3 2002, 18:16:26) [GCC 2.96 20000731 (Red Hat Linux 7.2 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 2/5.0
0.4
$ python2.2
Python 2.2.1 (#1, May 7 2002, 17:07:14)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2/5.0
0.40000000000000002
Dave
> From: Some One Else <nospam at any.time>
>
> Thank you Richard & Emile for your speedy responses!
>
> Still strange that a great book like LP showed a clean calculation ...
>
> Thanks!
> -s.o.e.
>
> Richard Jones wrote:
>
> > On Fri, 5 Jul 2002 10:10 am, Some One Else wrote:
> >> Hello!
> >>
> >> I just compiled and installed Python 2.2.1 on Linux-Mandrake 8.0. When I
> >>
> >> do the following:
> >> >>> 2/5.0
> >>
> >> 0.40000000000000002
> >>
> >> In 'Learning Python', a similar example says I should get the more
> >> logical
> >> answer of 0.4. Did I install something wrong? I can see where this could
> >> result in creeping math errors.
> >
> > Yes, this is normal :)
> >
> > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp
> >
> >
> > Richard
>
> --
>
>
More information about the Python-list
mailing list