> >>> from decimal import Decimal > >>> getcontext().prec = 32 > >>> Decimal(1) / Decimal(7) > Decimal("0.14285714285714285714285714285714") > > But I can't figure out how to compute to 32 places things like the > square root of 2, or the arc tangent of .41. Could someone please > show me?
The first is easy: >>> from decimal import getcontext >>> getcontext().prec = 32 >>> Decimal(2).sqrt() Decimal("1.4142135623730950488016887242097") actan(0.41) is trickier... because you need to use the math module >>> Decimal(str(math.atan(0.41))) 0.38909723105527838 And that limits the precision. If you were working with lower value precision - say 16 digits - then it would be OK. >>> getcontext().prec=12 >>> Decimal(str(math.atan(0.41))) Decimal("0.389097231055") >>> HTH, Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor