Title: int/long discrepancy when formatting zero with "%.0d"
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.7, Python 2.6
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mark.dickinson, terry.reedy
Priority: normal Keywords:

Created on 2009-11-16 18:28 by mark.dickinson, last changed 2010-08-10 21:34 by mark.dickinson. This issue is now closed.

Messages (3)
msg95356 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-11-16 18:28
In Python 2.x we have:

>>> "%.0d" % 0
>>> "%.0d" % 0L

In Python 3.x:

>>> "%.0d" % 0

I think the 2.x behaviour for int comes directly from C's sprintf 
behaviour:  section, p8 of the C99 standard says:

"The result of converting a zero value with a precision of zero is no 

I'm not sure which the more sensible behaviour is, but in 2.x, int and 
long should behave in the same way.  Fixing long to behave like int 
seems both simplest and least likely to break existing code.
msg95567 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-11-20 21:25
I agree with the 'should' (behave same way), but changing nothing will
break no code. Given that the purpose of 2.7 is to aid 3.x migration, an
argument could be made for matching the 3.x behavior.
msg113561 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-08-10 21:34
Out of date for 2.x.
Date User Action Args
2010-08-10 21:34:40mark.dickinsonsetstatus: open -> closed
resolution: out of date
messages: + msg113561
2009-11-20 21:25:50terry.reedysetnosy: + terry.reedy
messages: + msg95567
2009-11-16 19:23:34mark.dickinsonsettitle: int/long discrepancy when formatting zero with ".0d" -> int/long discrepancy when formatting zero with "%.0d"
2009-11-16 18:28:38mark.dickinsoncreate