On 2013-05-30, Chris Angelico <ros...@gmail.com> wrote: > On Thu, May 30, 2013 at 3:10 PM, Steven D'Aprano ><steve+comp.lang.pyt...@pearwood.info> wrote: >> # Wrong, don't do this! >> x = 0.1 >> while x != 17.3: >> print(x) >> x += 0.1 > > Actually, I wouldn't do that with integers either.
I propose borrowing the concept of significant digits from the world of Physics. The above has at least three significant digits. With that scheme x would approximately equal 17.3 when 17.25 <= x < 17.35. But I don't see immediately how to calculate 17.25 and 17.35 from 17.3, 00.1 and 3 significant digits. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list