Issue 3404: wrong precision in float formatting or doc error (original) (raw)

Issue3404

Created on 2008-07-18 10:40 by hagen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg69947 - (view) Author: Hagen Fürstenau (hagen) Date: 2008-07-18 10:40
This seems to be wrong: >>> "{0:.2}".format(1.2345) '1.2' The same happens for format specifiers "g" and "n", but not for "f": >>> "{0:.2f}".format(1.2345) '1.23' With empty format specifier it can even get really wrong: >>> "{0:.1}".format(1.2345) '1.0'
msg69948 - (view) Author: Hagen Fürstenau (hagen) Date: 2008-07-18 10:54
Just found it documented for the % operator: There precision is number of digits before and after decimal point for format "g". But then the documentation for 2.6 is wrong: "The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value."
msg69949 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-18 11:15
Fixed docs in r65099.
History
Date User Action Args
2022-04-11 14:56:36 admin set github: 47654
2008-07-18 11:15:17 georg.brandl set status: open -> closedresolution: fixedmessages: +
2008-07-18 10:54:22 hagen set title: wrong precision in float formatting -> wrong precision in float formatting or doc errornosy: + georg.brandlmessages: + assignee: georg.brandlcomponents: + Documentationtype: behavior ->
2008-07-18 10:40:25 hagen create