PEP 260: simplify xrange()

Dinu Gherman gherman at
Thu Jun 28 09:35:11 CEST 2001

Tim Peters wrote:
> >>> print len(frange(0.0, 1.0, 0.1))
> 11
> >>>
> That's the kind of "inexplicable" crap we don't want to have to try to
> explain <wink>:  repeated addition is a Bad Idea for floats.

IMHO this is not Python's fault, and all other languages that
don't rely on some sort of symbolic algebra should show the 
same "phenomenon".

> You can improve the numeric quality of the results by generating via
> [...]
> instead (repeated addition accumulates rounding errors without bound; the
> alternative suffers no more than 2 rounding errors (total) for each element
> produced).  Then it returns 10 elements in the example above.

This is an obvious improvement - thanks!


More information about the Python-list mailing list