[Python-Dev] Why don't range and xrange threat floats as floats? (original) (raw)
L V somelauw at yahoo.com
Wed Nov 5 19:26:35 CET 2008
- Previous message: [Python-Dev] Looking for VCS usage scenarios
- Next message: [Python-Dev] Why don't range and xrange threat floats as floats?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Why don't range and xrange threat floats as floats? Is there any good reason range and xrange don't threat floats as floats but as integers? When I enter float arguments in a range, the floats are treated as integers. (+ some warning)
This is how I think it should work:
range(0, 1, 0.1) [0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, 0.80000000000000004, 0.90000000000000002]
I got these results by:
[x/10. for x in xrange(10)]
I'm not looking for alternatives, just for the reason that it works this way.
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20081105/77193f89/attachment.htm>
- Previous message: [Python-Dev] Looking for VCS usage scenarios
- Next message: [Python-Dev] Why don't range and xrange threat floats as floats?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]