Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'true,': 0.05; 'exception.': 0.09; 'subject:Why': 0.09; 'cc:addr:python- list': 0.11; '42,': 0.16; 'all).': 0.16; 'division.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'thu,': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'mod': 0.31; 'sep': 0.31; '(i.e.': 0.33; 'could': 0.34; 'agree': 0.35; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'ian': 0.60; 'talking': 0.65; '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=H651D6JQxwMycGIebC7i9kS/Km7y5auMb1BBZad0Fw8=; b=VEGCw7FKzaL6KXTBUHIsT4SyssfYvYyKbjB589lxPnYxIDa2HeGfbst4q0j2cGuBCn qzujTG/JysubFqFc5TkZ/IACgziZfz7+1A4SkthTRo4eXRtrxDCW3/cnBJjbKOS2xOdt 96R3hSgQG3ADRDPu5xWF7CBdh8LrZDULBbbISl6fIV9wPkfAn8WKSvcTImF8zue6Kf+2 sCgAvGU+flzjgDlsHZV+go5gklN83dey+4hhkpytkSvldb+DhpgEKQ/DJrxGocm2ZVCZ vjuuGw0jZtII+T2RqpNS3w5ha986UTMIRIsdTJYPnQD1oin0vg1XRJSbINtDVOWgm6GT bzLQ== MIME-Version: 1.0 X-Received: by 10.42.231.9 with SMTP id jo9mr6358072icb.12.1410968401158; Wed, 17 Sep 2014 08:40:01 -0700 (PDT) In-Reply-To: References: <06397cb3-8baf-4af1-8152-ff7c3f6ceb62@googlegroups.com> <151e45ce-444d-441c-b59b-67e2aee3882b@googlegroups.com> Date: Thu, 18 Sep 2014 01:40:01 +1000 Subject: Re: Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))` From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410968410 news.xs4all.nl 2912 [2001:888:2000:d::a6]:57841 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77971 On Thu, Sep 18, 2014 at 1:34 AM, Ian Kelly wrote: > On Wed, Sep 17, 2014 at 9:29 AM, Chris Angelico wrote: >> On Thu, Sep 18, 2014 at 1:16 AM, cool-RR wrote: >>> I didn't ask for the modulo, I agree it should remain NaN. I'm talking about the floor division. >>> >> >> Invariant: div*y + mod == x. >> >> If mod is NaN, there is no possible value for div that will make the >> invariant true, ergo it too has to be NaN. > > That still doesn't make the invariant true. By this argument div could > be 42, and the invariant would hold equally well (i.e. not at all). Nothing can possibly make it true, so there are only two possibilities: return NaN, or raise an exception. ChrisA