Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8407
| References | <10b8388e-76fc-4a93-aeff-676cdb3d1d12@5g2000yqb.googlegroups.com> <4e04f793$0$29975$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2011-06-24 16:58 -0400 |
| Subject | Re: Significant figures calculation |
| From | Jerry Hill <malaclypse2@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.386.1308949143.1164.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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