Mark Dickinson wrote:
On Wed, Jul 16, 2008 at 3:35 PM, Eric Smith
<[EMAIL PROTECTED]> wrote:
Does anyone know why 'F' is the same as 'f'? Wouldn't it make more sense to
either drop it, or make it convert the exponent to upper case
What exponent? Isn't the point of 'f' formatting that there is no exponent?
There's no exponent until the number gets large. I haven't looked up
how big the number has to get. On my Mac, it's somewhere between 1e50
and 1e60.
$ ./python.exe
Python 3.0b1+ (py3k:64984:64985, Jul 15 2008, 20:17:06)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> '%f' % 1e100
'1e+100'
>>> '%F' % 1e100
'1e+100'
>>> '%f' % 1.2
'1.200000'
str.format() works the same.
In C, the only difference seems to be that a NaN or infinity formatted with '%F'
is turned into "NAN" or "INF" instead of "nan" or "inf".
Not so in Python.
>>> '%f' % float('nan')
'nan'
>>> '%F' % float('nan')
'nan'
But it is the case with 'e':
>>> '%e' % float('nan')
'nan'
>>> '%E' % float('nan')
'NAN'
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com