[issue13433] String format documentation contains error regarding %g
Christian Iversen c...@sikkerhed.org added the comment: Terry, the %g format always trims trailing zeroes, so you'd have to try with a number that doesn't end in zero. I had to make a re-implementation of format for javascript: http://paste.pocoo.org/show/513078/ If you look at the %g case, you can clearly see how much more complex and different it is, not that that itself indicates a bug. But it is different for sure :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13433 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13433] String format documentation contains error regarding %g
Christian Iversen c...@sikkerhed.org added the comment: Certainly, I don't think we should be peppering the docs with warnings and notes, either. However, the elements in question _already have_ notes. I propose that the note for %g (4) simply be updated for clarity. Something like this, perhaps: Unlike the other floating-point formats, the precision determines the number of significant digits before and after the decimal point and defaults to 6. Simply adding Unlike the other floating-point formats, at the beginning of the second line makes it much clearer that this is a different beast. If you feel that is not the right solution, then feel free to close this issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13433 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13433] String format documentation contains error regarding %g
New submission from Christian Iversen c...@sikkerhed.org: The documentation for string format options state that both %f, %g and %e default to 6 digits after the decimal point. In fact, %g always seems to use 5 digits by default: %g % 2.1234567 '2.12346' %f % 2.1234567 '2.123457' %e % 2.1234567 '2.123457e+00' But something much more insidious is wrong, because even when explicitly told how many digits to have, %g is one off: %.6g % 2.1234567 '2.12346' %.6f % 2.1234567 '2.123457' %.6e % 2.1234567 '2.123457e+00' This can't be right? -- assignee: docs@python components: Documentation messages: 147940 nosy: Christian.Iversen, docs@python priority: normal severity: normal status: open title: String format documentation contains error regarding %g type: behavior versions: Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13433 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13433] String format documentation contains error regarding %g
Christian Iversen c...@sikkerhed.org added the comment: That was exactly the page I was looking at, and after some discussion on #python, I can see how they differ. Perhaps this could be clarified in the documentation? It's very easy to miss as it is now. Maybe a note describing that %g is different from the others in this regard? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13433 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com