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

So how to do it?

Thanks,

Dick Moores
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to