On Mon, Nov 23, 2009 at 12:28 PM, Richard D. Moores <rdmoo...@gmail.com>wrote:
> Can't find the answer in the docs for 3.1 > > To print 123**34.6 to 5 sig digits, > > print("%.*e" % (4, 123**34.6)) > > will do the job: > > >>> print("%.*e" % (4, 123**34.6)) > 2.0451e+72 > > However, if the number is 123**346, using > > print("%.*e" % (4, 123**346)) > > gets me > > >>> print("%.*e" % (5, 123**346)) > Traceback (most recent call last): > File "<pyshell#28>", line 1, in <module> > print("%.*e" % (5, 123**346)) > OverflowError: Python int too large to convert to C double > Try the decimal module: http://docs.python.org/library/decimal.html HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor