[docs] [issue13433] String format documentation contains error regarding %g

Christian Iversen report at bugs.python.org
Sat Nov 19 14:01:32 CET 2011

New submission from Christian Iversen <ci at 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
>>> "%f" % 2.1234567
>>> "%e" % 2.1234567

But something much more insidious is wrong, because even when explicitly told how many digits to have, %g is one off:

>>> "%.6g" % 2.1234567
>>> "%.6f" % 2.1234567
>>> "%.6e" % 2.1234567

This can't be right?

assignee: docs at python
components: Documentation
messages: 147940
nosy: Christian.Iversen, docs at 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 <report at bugs.python.org>

More information about the docs mailing list