This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: %g incorrect conversion
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, phr
Priority: normal Keywords:

Created on 2006-05-18 04:31 by phr, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg28561 - (view) Author: paul rubin (phr) Date: 2006-05-18 04:31
According to
http://docs.python.org/lib/typesseq-strings.html

%g is the same as %f or %e depending on the exponent. 
Test:

Python 2.4.1 (#1, May 16 2005, 15:19:29)
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2

>>> x=.123999
>>> '%.4f'%x
'0.1240'
>>> '%.4g'%x
'0.124'
>>>

These are not the same.
msg28562 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-18 07:20
Logged In: YES 
user_id=849994

The conversion is actually correct, but the docs aren't.
Committed a fix in rev. 46038.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43373
2006-05-18 04:31:54phrcreate