[docs] [issue22546] Wrong default precision in documentation for format

Mark Dickinson report at bugs.python.org
Sat Oct 4 09:55:57 CEST 2014


Mark Dickinson added the comment:

> It seems that str, repr, and '' are using precision 16

None of them is using a fixed precision: they're all using David Gay's implementation of the "shortest string" algorithm (à la Burger and Dybvig).   For repr, this is the case since Python 3.1 / 2.7; for str and formatting with no type specifier, since Python 3.2.  The docs definitely do need updating here.

> I expected this last to be
> '33.14159265358979'

'33.1415926535898' is shorter, and rounds back to the same floating-point number, so that's what Gay's algorithm gives here.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22546>
_______________________________________


More information about the docs mailing list