working with VERY large 'float' and 'complex' types

Terry Hancock hancock at
Thu Sep 15 01:05:18 CEST 2005

> "Todd Steury" <sciurus1 at> writes:
> > or 1.#INDj. However I really need these numbers to be calculated (although 
> > precision isn't key). Is there a way to get python to increase the size 
> > limit of float and complex numbers?

This is really a natural problem with such calculations.

On Wednesday 14 September 2005 02:30 pm, Paul Rubin wrote:
> You could rearrange your formulas to not need such big numbers:
>     x = 1000.
>     log10_z = x / math.log(10)
>     c,m = divmod(log10_z, 1.)
>     print 'z = %.5fE%d' % (10.**c, m)

I highly recommend you use this kind of solution. Solve the problem
with algebra, not with a new library.  Most of the time, large numbers
can be avoided (particularly if you are not overly concerned with
precision), simply by dividing out large constant factors and the
like. Logs work better for this problem, as Paul points out.

Terry Hancock ( hancock at )
Anansi Spaceworks

More information about the Python-list mailing list