[Python-Dev] Two proposed changes to float formatting

Mark Dickinson dickinsm at gmail.com
Sun Apr 26 21:19:20 CEST 2009

On Sun, Apr 26, 2009 at 8:11 PM, Scott David Daniels
<Scott.Daniels at acm.org> wrote:
> As a user of Idle, I would not like to see the change you seek of
> having %f stay full-precision.  When a number gets too long to print
> on a single line, the wrap depends on the current window width, and
> is calculated dynamically.  One section of the display with a 8000
> -digit (100-line) text makes Idle slow to scroll around in.  It is
> too easy for numbers to go massively positive in a bug.

I see your point.  Since we're talking about floats, thought, there
should never be more than 316 characters in a '%f' % x: the
largest float is around 1.8e308, giving 308 digits before the
point, 6 after, a decimal point, and possibly a minus sign.
(Assuming that your platform uses IEEE 754 doubles.)

> However, this is, I agree, a problem.  Since all of these numbers
> should end in a massive number of zeroes

But they typically don't end in zeros (except the six zeros following
the point),
because they're stored in binary rather than decimal.  For example:

>>> int(1e308)


More information about the Python-Dev mailing list