Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85662

Re: Floating point "g" format not stripping trailing zeros

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.048
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'programmer': 0.03; 'subject:not': 0.03; 'lesser': 0.07; 'trailing': 0.09; '1.20': 0.16; 'measured': 0.16; 'subject:format': 0.16; 'url:decimal': 0.16; 'wording': 0.16; 'zeros': 0.16; 'wrote:': 0.18; 'module': 0.19; 'figures': 0.19; 'result.': 0.19; 'written': 0.21; 'seems': 0.21; 'feb': 0.22; '>>>': 0.22; 'appears': 0.22; 'instance,': 0.24; 'fine': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'returned': 0.30; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; 'url:wiki': 0.31; '1.3': 0.31; '13,': 0.31; '>>>>': 0.31; 'decimal': 0.31; 'though.': 0.31; 'url:wikipedia': 0.31; 'url:python': 0.33; 'fri,': 0.33; 'guess': 0.33; 'could': 0.34; 'agree': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'dave': 0.60; 'ian': 0.60; 'tell': 0.60; 'places': 0.64; 'kept': 0.65; 'skip:\xe2 10': 0.65; 'talking': 0.65; 'here': 0.66; '2015': 0.84; 'confusing': 0.84; 'significance': 0.84; 'angel': 0.91; 'edwards': 0.91; 'notion': 0.91; 'hand,': 0.93; 'taught': 0.96
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:to :content-type:content-transfer-encoding; bh=jZQ6GF6E6z+Vn0HI6ra4uJitS6f6+cNd6IQfQvyx+qs=; b=T/J+84sK/J0j32jEsIxc90t8H1qnXhqxeg4FNYMfF598iiDMj1h7UPXRowOJtFhw3J QheDzjQTGhx5HoJYsvFALPAAed32YOz1tgNZbdXFR/6Y+fXR/jxoKXrl6bq3hE8ZsZDM PfiWY/e1F3kd6JLEXqcbenFoLjl2Fr0rwy0KXjImB0zZF0v205Bd6/HR9fOFD3QCReGQ x+shGN/Smva2yRle3HfduxkqQ6+e7hqVzsf71AxCmQLXlJW8Urkyi1gEZb55xzThE9Ro jGXya2aGFpj0eUXRsGCPYFuUiBa2cKrSuu6mDGFQ8Ah+ZSUZPY0jKWgBg26Cd9HKCvTX qMzw==
X-Received by 10.68.239.69 with SMTP id vq5mr18712631pbc.96.1423864194150; Fri, 13 Feb 2015 13:49:54 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CALwzidmDYcsBTFENJ9hu9PL-kdo_m0==NyZrnC6rVSjcUZRUBA@mail.gmail.com>
References <CAK291fpAycSecNuV6hDnVXK+rhB0CWJTAuC3BKNUz8B4aDg2kQ@mail.gmail.com> <CAK291fpKxW_V=yCvNHj9RRoEhC=i_DYJCa9-cbjxDwRwH4-KfQ@mail.gmail.com> <mailman.18715.1423784816.18130.python-list@python.org> <mbl04r$kb6$1@reader1.panix.com> <mailman.18731.1423846637.18130.python-list@python.org> <mbln2c$9k5$1@reader1.panix.com> <mailman.18734.1423862121.18130.python-list@python.org> <mblpv0$2v6$1@reader1.panix.com> <CALwzidmDYcsBTFENJ9hu9PL-kdo_m0==NyZrnC6rVSjcUZRUBA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 13 Feb 2015 14:49:13 -0700
Subject Re: Floating point "g" format not stripping trailing zeros
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18736.1423864203.18130.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423864203 news.xs4all.nl 2882 [2001:888:2000:d::a6]:37633
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85662

Show key headers only | View raw


On Fri, Feb 13, 2015 at 2:40 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards <invalid@invalid.invalid> wrote:
>> On 2015-02-13, Dave Angel <davea@davea.name> wrote:
>>> On the other hand, the Decimal package has a way that the programmer
>>> can tell how many digits to use at each stage of the calculation.
>>
>> That's what surpised me.  From TFM:
>>
>> https://docs.python.org/2/library/decimal.html:
>>
>>  * The decimal module incorporates a notion of significant places so that
>>    1.30 + 1.20 is 2.50. The trailing zero is kept to indicate
>>    significance. This is the customary presentation for monetary
>>    applications. For multiplication, the “schoolbook” approach uses
>>    all the figures in the multiplicands. For instance, 1.3 * 1.2 gives
>>    1.56 while 1.30 * 1.20 gives 1.5600.
>
> Huh. That approach for multiplication is definitely not what I was
> taught in school. I was taught that the number of significant digits
> in the product is the lesser of the number of significant digits in
> either of the measured multiplicands. So 1.30 * 1.20 would be 1.56,
> while 1.3 * 1.2 would just be 1.6. Wikipedia appears to agree with me:
>
> http://en.wikipedia.org/wiki/Significance_arithmetic#Multiplication_and_division_using_significance_arithmetic
>
> Moreover:
>
>>>> D('1.304') * D('1.204')
> Decimal('1.570016')
>>>> D('1.295') * D('1.195')
> Decimal('1.547525')
>
> So 1.30 * 1.20 could be written approximately as 1.56 ± 0.01. Given
> that, I don't understand how the trailing zeros in 1.5600 could
> possibly be considered significant.

I guess the point here is that the paragraph isn't really talking
about significance arithmetic; it's explaining how it decides how many
digits to keep in the result. It may be fine for 1.30 * 1.20 to return
1.56, but it would be very confusing if 1.35 * 1.25 returned 1.69
instead of 1.6875. The wording of the paragraph seems misleading,
though.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Floating point "g" format not stripping trailing zeros Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-12 16:46 -0700
  Re: Floating point "g" format not stripping trailing zeros Grant Edwards <invalid@invalid.invalid> - 2015-02-13 14:02 +0000
    Re: Floating point "g" format not stripping trailing zeros Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-13 09:56 -0700
      Re: Floating point "g" format not stripping trailing zeros Grant Edwards <invalid@invalid.invalid> - 2015-02-13 20:33 +0000
        Re: Floating point "g" format not stripping trailing zeros Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-13 14:01 -0700
        Re: Floating point "g" format not stripping trailing zeros Dave Angel <davea@davea.name> - 2015-02-13 16:15 -0500
          Re: Floating point "g" format not stripping trailing zeros Grant Edwards <invalid@invalid.invalid> - 2015-02-13 21:22 +0000
            Re: Floating point "g" format not stripping trailing zeros Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-13 14:40 -0700
            Re: Floating point "g" format not stripping trailing zeros Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-13 14:49 -0700

csiph-web