Path: csiph.com!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: Short-circuit Logic Date: 30 May 2013 19:30:41 GMT Organization: Norwich University Lines: 22 Message-ID: References: <5f101d70-e51f-4531-9153-c92ee2486fd9@googlegroups.com> <51a1fc7b$0$30002$c3e8da3$5496439d@news.astraweb.com> <2abf4e9c-8c3b-4e2f-80c9-50c1f1d75c9d@googlegroups.com> <51a4b5a1$0$29966$c3e8da3$5496439d@news.astraweb.com> <04b90c02-833a-4bad-88ad-ab71178b8f79@googlegroups.com> <51a6df59$0$11118$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net DBMz+CeaQvJ3rhaZ9QHoqw+w7hQAOdMP6fR+9DAtlvlNnviaP0 Cancel-Lock: sha1:cv0uIsKKfxiv1X9KfZdiE/d12/0= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:46536 On 2013-05-30, Chris Angelico wrote: > On Thu, May 30, 2013 at 3:10 PM, Steven D'Aprano > 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