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


Groups > comp.lang.python > #8407

Re: Significant figures calculation

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <malaclypse2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'function,': 0.07; '>>>>': 0.09; 'curious.': 0.09; 'dynamically': 0.09; 'wrote:': 0.15; 'docs,': 0.16; 'obvious.': 0.16; 'really?': 0.16; 'significance': 0.16; 'pm,': 0.16; 'header:In-Reply-To:1': 0.22; 'received:209.85.215.46': 0.23; 'received:mail- ew0-f46.google.com': 0.23; "i'm": 0.27; 'fri,': 0.28; 'message- id:@mail.gmail.com': 0.28; 'import': 0.29; "didn't": 0.29; '24,': 0.29; 'precision': 0.30; 'setting': 0.32; 'there': 0.34; 'to:addr :python-list': 0.34; 'anything': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'steven': 0.38; 'subject:: ': 0.38; 'spent': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'skip:d 20': 0.40; 'within': 0.60; 'minutes': 0.67; 'jun': 0.67; 'browsing': 0.77
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=733X1crMhOyw5iogy00rhiesIEbVbYZ+SmBnkgbDakM=; b=GVZdAqEeX0YnKr9KLYj8U9moXmRgEX0sd4sJQQZWcrPbrmbl62OduhoGGtxAm5KZ9l VXQb1pLzlB1gYupaTKX4Ib3KLQyDuD25cCG0CwyIX4/BIb9SjxXVJ6UzJLYwlCW0gVtm FhkzKxmvRRjH2+mNkT9AAM01YVWlDaAyzu4g0=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=IgfcgavUz4Uw9YRaeDHxCjTiQXOeVikEtctgZiauL1gyNiM/9IKvWVd0vJ8IfdHQjv eDrfzgOnT1TMqLf88AnE0Cb614LE1Ns4oK3Ywpdfq17rAllgNNDjR2Ray5D4yoDE71EV DSnQkY6I5Ep6fZi2dPHxTAp5M0TcM6y0uM4d4=
MIME-Version 1.0
In-Reply-To <4e04f793$0$29975$c3e8da3$5496439d@news.astraweb.com>
References <10b8388e-76fc-4a93-aeff-676cdb3d1d12@5g2000yqb.googlegroups.com> <4e04f793$0$29975$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 24 Jun 2011 16:58:56 -0400
Subject Re: Significant figures calculation
From Jerry Hill <malaclypse2@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.386.1308949143.1164.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 82.94.164.166
X-Trace 1308949144 news.xs4all.nl 510 [::ffff:82.94.164.166]:50498
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8407

Show key headers only | View raw


On Fri, Jun 24, 2011 at 4:46 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Really? It works for me.
>
>>>> import decimal
>>>> D = decimal.Decimal
>>>> decimal.getcontext().prec = 2
>>>>
>>>> D('32.01') + D('5.325') + D('12')
> Decimal('49')

I'm curious.  Is there a way to get the number of significant digits
for a particular Decimal instance?  I spent a few minutes browsing
through the docs, and didn't see anything obvious.  I was thinking
about setting the precision dynamically within a function, based on
the significance of the inputs.

-- 
Jerry

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


Thread

Significant figures calculation Harold <dadapapa@googlemail.com> - 2011-06-24 13:05 -0700
  Re: Significant figures calculation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-24 20:46 +0000
    Re: Significant figures calculation Jerry Hill <malaclypse2@gmail.com> - 2011-06-24 16:58 -0400
      Re: Significant figures calculation steve+comp.lang.python@pearwood.info - 2011-06-25 10:31 +1000
      Re: Significant figures calculation Chris Torek <nospam@torek.net> - 2011-06-25 19:04 +0000
        Re: Significant figures calculation Harold <dadapapa@googlemail.com> - 2011-06-26 08:35 -0700
          Re: Significant figures calculation Dave Angel <davea@ieee.org> - 2011-06-27 08:04 -0400
        Re: Significant figures calculation Harold <dadapapa@googlemail.com> - 2011-06-27 06:40 -0700
          Re: Significant figures calculation Ethan Furman <ethan@stoneleaf.us> - 2011-06-27 13:53 -0700
            Re: Significant figures calculation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-28 12:56 +1000
              Re: Significant figures calculation Chris Angelico <rosuav@gmail.com> - 2011-06-28 13:16 +1000
                Re: Significant figures calculation Erik Max Francis <max@alcyone.com> - 2011-06-27 20:45 -0700
                Re: Significant figures calculation Mel <mwilson@the-wire.com> - 2011-06-28 07:47 -0400
                Re: Significant figures calculation Chris Angelico <rosuav@gmail.com> - 2011-06-28 21:57 +1000
                Re: Significant figures calculation Erik Max Francis <max@alcyone.com> - 2011-06-28 11:54 -0700
                Re: Significant figures calculation Mel <mwilson@the-wire.com> - 2011-06-28 16:47 -0400
                Re: Significant figures calculation Erik Max Francis <max@alcyone.com> - 2011-06-28 14:01 -0700
                Re: Significant figures calculation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-28 18:35 +1000
                Re: Significant figures calculation Erik Max Francis <max@alcyone.com> - 2011-06-28 11:59 -0700
              Re: Significant figures calculation Erik Max Francis <max@alcyone.com> - 2011-06-27 20:49 -0700
          Re: Significant figures calculation Ethan Furman <ethan@stoneleaf.us> - 2011-06-27 15:58 -0700
    Re: Significant figures calculation Harold <dadapapa@googlemail.com> - 2011-06-24 18:50 -0700

csiph-web