Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!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; 'true,': 0.05; 'wednesday,': 0.07; 'subject:Why': 0.09; 'cc:addr:python-list': 0.11; 'developers,': 0.11; 'chris,': 0.16; 'division.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'documented': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'mod': 0.31; 'sep': 0.31; 'maybe': 0.34; 'agree': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'like,': 0.36; 'returning': 0.36; "didn't": 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'whatever': 0.38; 'expect': 0.39; 'more': 0.64; '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=n/c7mzZiHEOcpzH/2DqYrCUAgnm3yXp+hgHpKI6ZyXA=; b=WQK/ycavhMYtUyyOqDwSwRTfNVZON52vCih9aeJc1tqbOkW3jvLGfNQFCle6nTKWdk +3bvdk+Le3w3t8+CHsoOw7TO15LcjzwO3Kt85iHgeFx0Aaex6bha2ARFKP5YkQJymwZM TNBSBK54k0XQyVxc7J1LvnHyTpuqcSXnaM4QpJ8uHMCXmIG5vdsA4X0eSSS0CelvZ1qa jUO2pYPzTTjFYQVVCZGC95eMA6L/GwW2WYUB3jcwrbSPceEBe60Z8Twu1QB4961lztQg ybhgq+nB94PByrhTICXIShnx48y+56XInJflPv9Ky0/AmtD/PcLxCJ86a9nlRswYOqFY 5Ivw== MIME-Version: 1.0 X-Received: by 10.51.17.2 with SMTP id ga2mr5782068igd.2.1410971870745; Wed, 17 Sep 2014 09:37:50 -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 02:37:50 +1000 Subject: Re: Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))` 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.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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410971877 news.xs4all.nl 2974 [2001:888:2000:d::a6]:56323 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77979 On Thu, Sep 18, 2014 at 2:33 AM, cool-RR wrote: > On Wednesday, September 17, 2014 6:30:04 PM UTC+3, 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. >> ChrisA > > Chris, why is this invariant `div*y + mod == x` so important? Maybe it's more important to return a mathematically reasonable result for the the floor-division result than to maintain this invariant? It's important because it's documented :) You can expect whatever you like, but if something's a documented invariant, that's more important than your expectations. Now, why was divmod documented as returning values adhering to that invariant? You'd have to ask the developers, I've no idea. ChrisA