[issue1600] str.format() produces different output on different platforms (Py30a2)

Christian Heimes report at bugs.python.org
Sat Dec 15 22:14:18 CET 2007


Christian Heimes added the comment:

Guido is right. On Linux the system's sprintf() family prints %e, %g and
%f with two or three digits while Windows always uses three digits:

Linux
>>> "%e" % 1e1
'1.000000e+01'
>>> "%e" % 1e10
'1.000000e+10'
>>> "%e" % 1e100
'1.000000e+100'

Windows
>>> "%e" % 1e1
'1.000000e+001'
>>> "%e" % 1e10
'1.000000e+010'
>>> "%e" % 1e100
'1.000000e+100'

The output could be changed in any of the functions:
Objects/floatobject.h:format_double()
Python/pystrtod.c:PyOS_ascii_formatd()
Python/mysnprint.c:PyOS_snprintf()

----------
keywords: +py3k
nosy: +tiran
versions: +Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1600>
__________________________________


More information about the Python-bugs-list mailing list