Best search algorithm to find condition within a range

Chris Angelico rosuav at gmail.com
Thu Apr 9 10:08:27 EDT 2015


On Thu, Apr 9, 2015 at 11:57 PM, Alain Ketterlin
<alain at dpt-info.u-strasbg.fr> wrote:
> Because, in:
>
>     z = x+y; // all signed ints
>     if ( z < x )
>         ...
>
> either there was no overflow (and the condition is false), or there was,
> and the result is undefined, i.e., "z<x" can be considered false also.

Do you mean "all unsigned ints" here? Because if y is negative, the
condition will be true without overflow. If you didn't, then I'm
puzzled as to where the undefined behaviour is coming from.

ChrisA



More information about the Python-list mailing list