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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Fri, Jun 24, 2011 at 4:46 PM, Steven D'Aprano 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