Best search algorithm to find condition within a range

Chris Angelico rosuav at gmail.com
Thu Apr 9 18:43:12 CEST 2015


On Fri, Apr 10, 2015 at 2:25 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> As far as it's concerned, it's impossible for a CPU register to
>> arbitrarily change without notice. It's equally impossible for the
>> addition of two positive signed integers to result in a negative
>> integer.
>
> The standard says that any program that takes a signed integer out of
> its valid range is broken and deserves anything that happens to it.
>
> I say it's the standard that is broken.

For application work, it's usually much better to have an integer type
like Python's or Pike's int - a signed integer that can never
overflow. For low-level bit manipulation work, you usually want an
*unsigned* integer of specific size, with well defined wrap-around
behaviour. When do you actually want a signed integer with
well-defined overflow behaviour?

ChrisA



More information about the Python-list mailing list