[Python-Dev] Different float formatting on Windows and Linux

Eric Smith eric+python-dev at trueblade.com
Mon Feb 18 12:12:11 CET 2008

The tests for float.__format__ are breaking on Windows, because of this 
issue: http://bugs.python.org/issue1600.  Basically, Windows is using 3 
digits for exponents < 100, and Linux (and at least MacOS) are using 2.

The patch attached to the issue proposes changing all platforms to use 
at least 3 digits.  It affects both '%' formatting and __format__ 
formatting.  Altering all float formatting involving exponents is a 
pretty big change to make, and I want to get opinions here before making 
this change.

Guido's comments in the issue are supportive, and I agree that the 
consistency would be good.  I'm just concerned about changing the output 
for existing code.

I suppose another option would be to modify Windows to use 2 digits for 
exponents < 100.  I guess it just depends on whose output you want to break!

I think the options are:
1: Do nothing.  Adapt the tests to deal with the differences.
2: Force 3 characters for exponents < 100.
3: Force 2 characters for exponents < 100.


More information about the Python-Dev mailing list