[Python-Dev] Re: Re: Decimal type question [Prothon]

Guido van Rossum guido at python.org
Thu Aug 12 05:00:30 CEST 2004


> For instance:
> 
>     >>> accumulator = 0.0
>     >>> for i in range(25000):
>     ...     accumulator += 1.0
>     ...
>     >>> print accumulator
>     25000.0
> 
> Notice, perfect accuracy. Yet people don't tend to use floating
> point for loops... why not?

Because the generalization to using fractions doesn't work.  Try the
same with adding 0.1, 25000 times.  Better not be tempted.

--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list