Short-circuit Logic

Neil Cerutti neilc at norwich.edu
Thu May 30 15:30:41 EDT 2013


On 2013-05-30, Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, May 30, 2013 at 3:10 PM, Steven D'Aprano
><steve+comp.lang.python at 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



More information about the Python-list mailing list