Author Christian.Iversen
Recipients Christian.Iversen, docs@python
Date 2011-11-19.13:01:31
SpamBayes Score 0.000311351
Marked as misclassified No
Message-id <1321707692.58.0.601543510069.issue13433@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2011-11-19 13:01:32Christian.Iversensetrecipients: + Christian.Iversen, docs@python
2011-11-19 13:01:32Christian.Iversensetmessageid: <1321707692.58.0.601543510069.issue13433@psf.upfronthosting.co.za>
2011-11-19 13:01:31Christian.Iversenlinkissue13433 messages
2011-11-19 13:01:31Christian.Iversencreate