Best search algorithm to find condition within a range

MRAB python at mrabarnett.plus.com
Thu Apr 9 18:40:37 CEST 2015


On 2015-04-09 16:21, Steven D'Aprano wrote:
> On Fri, 10 Apr 2015 01:02 am, Chris Angelico wrote:
>
>> On Fri, Apr 10, 2015 at 12:53 AM, Alain Ketterlin
>> <alain at dpt-info.u-strasbg.fr> wrote:
>>> Ouch, you're right, I tried to stick with Marko's example and forgot the
>>> basics. I meant "signed ints", but the "removable" condition should be
>>> something like:
>>>
>>>     if ( x>0 && y>0 && z<x )
>>>         ...
>>>
>>> i.e., some condition that is never true (either false or undefined).
>>> Thanks for the correction.
>>
>> Ah, yep. And yes, that's absolutely right - the compiler's allowed to
>> treat that as never true.
>
> Am I missing something? Did you over-trim the quoting?
>
> How can the compiler possibly be allowed to treat x>0 && y>0 && z<x as
> always false?
>
> x = y = 1
> z = 0
>
> gives x>0 && y>0 && z<x as true.
>
Earlier in the thread there was the line:

     z = x+y; // all signed ints




More information about the Python-list mailing list