Setting longer default decimal precision

Kay Y. Jheallee nospam at use.net
Wed Nov 20 14:34:55 EST 2013


On 13.Nov.20.Wed 14:02, Steven D'Aprano wrote:> Hi Kay,
 >
 > You emailed me off-list, but your email address is bouncing or 
invalid,
 > so I have no way to email you back.

So THAT's where it went!  Sorry about that...yes, it WAS meant 
for the group :/!

 > [you wrote]
 > Okay,but after I import "math" and "decimal",
 >
 > py> decimal.getcontext().prec=75
 > py> print decimal.Decimal(math.atan(1))
 > 0.78539816339744827899949086713604629039764404296875
 >
 > though I set precision to 75, it only did the trig function to
 > 50 places AND it is only right to 16 places,
 >
 > 0.785398163397448309615660845819875721049292349843776...
 > (actual).
 > [end quote]
 >
 >
 > Here, you calculate the atan of 1 using floating point maths,
 > that is, to the precision of C doubles (about 17 decimal
 > places). After the calculation is performed using float, you
 > then convert it to a Decimal,
 > but it is too late, you can't retroactively regain precision.
 >
 > In a perfect world, this would work:
 >
 > math.atan(Decimal(1))
 >
 > but alas, all the functions in the math module convert their
 > arguments to float first, so even though your Decimal(1)
 > could perform calculations to 75 decimal places, the
 > math.atan function downgrades it to a regular float.

Then that is useless! :(

 > You could try this third-party module:
 >
 > http://code.google.com/p/mpmath/‎

Ah, that looks like just the puppy I'm looking for. :)
Okay then, I just installed the PortableApps version of Python,
but when I downloaded "mpmath-0.17.win32" the installer aborted 
with "No Python installation found in the registry".
So I'm trying to install "setuptools 1.4" (and do it that way) at

    https://pypi.python.org/pypi/setuptools/1.4

but where is the "Download" link ("Downloads" just shifts down to 
the page section)?  I'm just looking for the ".zip" file version 
(if one exists), not ".tar.gz".
Thx!

-- 
Kill Hector dead, because Desi sent Milli.



More information about the Python-list mailing list