Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'broken': 0.04; 'integers': 0.09; 'overflow': 0.09; 'cc:addr:python-list': 0.11; 'arbitrarily': 0.16; 'behaviour.': 0.16; 'broken.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'overflow.': 0.16; 'subject:search': 0.16; 'size,': 0.16; 'wrote:': 0.18; 'bit': 0.19; "python's": 0.19; 'work,': 0.20; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'cc:2**0': 0.24; 'defined': 0.27; 'signed': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'usually': 0.31; 'says': 0.33; 'fri,': 0.33; 'received:google.com': 0.35; 'positive': 0.37; 'application': 0.37; 'two': 0.37; 'anything': 0.39; 'negative': 0.60; 'range': 0.61; '2015': 0.84; 'deserves': 0.84; 'subject:find': 0.84; 'subject:Best': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=TkKqgLAIIAKeKAzWStJmylyxmjl6IvTWniQmVnTqjf8=; b=rPjOG3bpr4pcD+zuc3c1Omj0KE+w3Za7WeN0tBHdWdNMoYAV1Mijyg5QvcE3w9MACX 6rFvRXXuWRmcqw6drspOud+DQh8NP0cFDcm0A+wa4KqIRT81YGhdi/EllkhbumbuV5Gi vLejNx+QihyjpdGS0nxW+/jxV8TcwJV3+CGEx1Holf1xn+K7WM9FvA2Cq1I1PaIDSoMN Y5LlnZEEOAOVxh7qxOcOD4Vc0yF9WuKA3b8ZbmwrDNv6Vzhn0ckA9e4j/qfbVB2xlxYd JDyJiEUofzS0MflRySpyT34Me+KE1aUOr/zfj1RU2/9YgCA7EfKVqU3y2VV94H8xtI6x eMeg== MIME-Version: 1.0 X-Received: by 10.50.9.97 with SMTP id y1mr21659234iga.34.1428597792627; Thu, 09 Apr 2015 09:43:12 -0700 (PDT) In-Reply-To: <87y4m1b76f.fsf@elektro.pacujo.net> References: <2e3a3c01-20b3-4948-9b32-bd80ed46822b@googlegroups.com> <552460cc$0$13002$c3e8da3$5496439d@news.astraweb.com> <876196cm1e.fsf@elektro.pacujo.net> <87k2xlzknu.fsf@elektro.pacujo.net> <8738498qf7.fsf@dpt-info.u-strasbg.fr> <87fv89zd0m.fsf@elektro.pacujo.net> <87y4m1795n.fsf@dpt-info.u-strasbg.fr> <874mopzarw.fsf@elektro.pacujo.net> <552696be$0$13012$c3e8da3$5496439d@news.astraweb.com> <87y4m1b76f.fsf@elektro.pacujo.net> Date: Fri, 10 Apr 2015 02:43:12 +1000 Subject: Re: Best search algorithm to find condition within a range From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428597801 news.xs4all.nl 2875 [2001:888:2000:d::a6]:37263 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88740 On Fri, Apr 10, 2015 at 2:25 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> 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