Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: What exactly is "exact" (was Clean Singleton Docstrings) Date: Mon, 18 Jul 2016 15:48:50 +1000 Lines: 49 Message-ID: References: <7046c74e-e5ea-4dde-8847-8c556756a563@googlegroups.com> <5789B601.9000604@stoneleaf.us> <9d2a0934-bf26-42a8-9bb2-e4e75b2d2ad3@googlegroups.com> <1468652038.1427719.667878897.460955C0@webmail.messagingengine.com> <578a027c$0$1616$c3e8da3$5496439d@news.astraweb.com> <69d8d886-c18a-4c05-8bca-9a05afacd9a9@googlegroups.com> <4a5bcb6a-6fc9-4c60-a24c-0c2dc3ffcb19@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de tINU+EAvzIsSoDhveyLj9gXzNSTd07GmFVrz1eOhieCg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'float': 0.05; 'attributes': 0.07; 'override': 0.07; 'pypi': 0.07; 'cc:addr :python-list': 0.09; 'answering': 0.09; 'constants.': 0.09; 'way:': 0.09; '2016': 0.16; 'constants': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literals': 0.16; 'literals,': 0.16; 'non-integers': 0.16; 'programmer,': 0.16; 'pushes': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Singleton': 0.16; 'syntactic': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'attribute': 0.18; 'instance,': 0.18; 'integer': 0.18; '(in': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'claiming': 0.22; 'implicit': 0.22; '(or': 0.23; 'header:In-Reply- To:1': 0.24; 'mon,': 0.24; 'sort': 0.25; 'chris': 0.26; 'error': 0.27; 'define': 0.27; 'least': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; '3.0': 0.27; 'function': 0.28; 'values': 0.28; 'arithmetic': 0.29; 'decimal': 0.29; 'operations': 0.31; 'core': 0.32; 'language.': 0.32; 'point': 0.33; 'problem': 0.33; '(for': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'asking': 0.35; 'but': 0.36; 'monday,': 0.36; 'structures': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; '(with': 0.38; 'mean': 0.38; 'why': 0.39; 'does': 0.39; 'rather': 0.39; 'some': 0.40; 'suitable': 0.61; 'skip:u 10': 0.61; 'default': 0.61; 'lose': 0.63; 'different': 0.63; 'within': 0.64; 'between': 0.65; 'believe': 0.66; 'designers': 0.72; 'jul': 0.72; '(word': 0.84; 'captures': 0.84; 'chrisa': 0.84; 'distinguish': 0.84; 'utc+5:30,': 0.84; 'to:none': 0.91; 'faith': 0.91; 'realization': 0.91; 'eliminates': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-transfer-encoding; bh=Wu13TuWZWawqCCgVrY18n18zu59O/ldmMXOSc1u50L4=; b=FGvcgVv1rtoEBaYMyndHh8bw0Ct4X5zo5SIKllqOE8BFR2jpPftZptb25Xc/89GaHT fyD7RR8+QPp1Gm13mBzmDey4Zt947JybSR4ncfLgbOqswUBlEAA2bcbYu0SIKAeqfodS rwXMxhT0CBM42ND9Zn+hQE4tkPKU5bafU3ZeOt/LCpAcatpdFpAKOMrjfnqR0pRgPM6m TniUtoRV53l0yRnCzz5YIcrW/VmZR6SODTY2Ynm29vH35DcfG2Xx5sExmoBVdRCzmqgh RQSE5/X8WGGyFeOSRwE5siKjQB++DRj5rKsJQpnwD6hv2jKJU1xhd+L2QzOSv5ESnSzr dJKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc:content-transfer-encoding; bh=Wu13TuWZWawqCCgVrY18n18zu59O/ldmMXOSc1u50L4=; b=IJYN4v76m1maNKJ9U5LvguVggdzCsmCy5d8s4fCjcIdPs0+cv8mCk9+lew2kNb+I6Y 8mqM+lEtKzj+2EoR1OpCSmdE+T3GW4AJJLYkZ1LJ036Shzg6cN/84kHNutfA6WY2Z5+S qLmZAv+Gs20fms0MrytBT+EONXkU9HuCBJcu+2WQg7nqqWMgONJseZSXWKXPDRYFXS+R 0QXQ0HqDMId66XB2tsVdahKIVozCoRzNh6F5iJZso7WkFMzytoDXd/00bF8+E7hewZF3 g5GjVsySLe/kMJWrGkaO7n/jsqHnti2nmsS8+ATCfklMlNpm2xWeu6g9wm/cR7K7YI2H J5UQ== X-Gm-Message-State: ALyK8tIFYKGa3jupOdU/HsJRfF/j1wsLxKi90WRMkIdTtJJlS/7J2rPw4S4ZqcMBJXQFvC0VWXAwlK7oEqFBIw== X-Received: by 10.28.87.3 with SMTP id l3mr53874980wmb.71.1468820931074; Sun, 17 Jul 2016 22:48:51 -0700 (PDT) In-Reply-To: <4a5bcb6a-6fc9-4c60-a24c-0c2dc3ffcb19@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <7046c74e-e5ea-4dde-8847-8c556756a563@googlegroups.com> <5789B601.9000604@stoneleaf.us> <9d2a0934-bf26-42a8-9bb2-e4e75b2d2ad3@googlegroups.com> <1468652038.1427719.667878897.460955C0@webmail.messagingengine.com> <578a027c$0$1616$c3e8da3$5496439d@news.astraweb.com> <69d8d886-c18a-4c05-8bca-9a05afacd9a9@googlegroups.com> <4a5bcb6a-6fc9-4c60-a24c-0c2dc3ffcb19@googlegroups.com> Xref: csiph.com comp.lang.python:111593 On Mon, Jul 18, 2016 at 3:37 PM, Rustom Mody wrote: > On Monday, July 18, 2016 at 10:06:11 AM UTC+5:30, Chris Angelico wrote: >> Why does that mean that 3.0 is inexact? In what way is 3.0 "inexact"? >> It's an exact value representing the integer three. > > [Assuming you are asking in good faith and in the same vein I am answerin= g > without claiming to know all this with much certainty] [Yes, I was] > I believe we need to distinguish between the intention and its realizatio= n > within the syntactic (in this case lexical) structures of the language. > > The INTENTION is that in addition to capturing the usual number tower > =E2=84=95 =E2=8A=82 =E2=84=A4 =E2=8A=82 =E2=84=9D (or parts therefore) > scheme also captures ORTHOGONALLY (word in the docs) the (in)exactness at= tribute > > In the realization, the designers need to (over)load these different attr= ibutes > onto numeric constants. > So the ruse chosen is that fraction-constants by default are exact > Decimal constants are inexact > And one can override any of these by suitable a function > [At least that's my understanding] Ah. Okay. So in theory, you could have exact float literals and inexact integer literals, if you tag them in some way: 300 ; Exactly 300 300! ; Inexact - roughly 300 3.0 ; Exactly three 3.0! ; Roughly three and zero tenths This then eliminates the problem of representing exact non-integers (for instance, IEEE floating point has no problem representing exactly 3.125, but if all floats are automatically "inexact", you lose that facility), but it then pushes the question of "what does inexact really MEAN" up to the programmer, at which point it really ends up in the domain of error values rather than a simple flag "inexact". In Python, this sort of thing would be perfect as a PyPI package - "numbers with error values" - which could then define all arithmetic operations and how they combine error values (with an implicit upcast from any numeric type to "number with error value of +/- 0"). It wouldn't need to be part of the core language. ChrisA