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.

Author terry.reedy
Recipients Barium, docs@python, eric.smith, mark.dickinson, terry.reedy
Date 2014-10-03.20:23:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412367798.18.0.799214799623.issue22546@psf.upfronthosting.co.za>
In-reply-to
Content
"The precision is a decimal number indicating how many digits should be displayed ... before and after the decimal point for a floating point value formatted with 'g' or 'G'. It seems that str, repr, and '' are using precision 16, and the doc should be changed to match.

>>>str(.314159265358979323846264338327950288419)
'0.3141592653589793' # 16, not counting 0.

>>> '{}'.format(3.14159265358979323846264338327950288419)
'3.141592653589793'
>>> '{:.16g}'.format(3.14159265358979323846264338327950288419)
'3.141592653589793'
>>> str(3.14159265358979323846264338327950288419)
'3.141592653589793'  # 16

But I discovered this 'anomaly' (bug?)
>>> str(31.4159265358979323846264338327950288419)
'31.41592653589793'
>>> str(33.14159265358979323846264338327950288419)
'33.1415926535898'  # precision 15
I expected this last to be
'33.14159265358979'
as 32... rounds down, not up.

repr and '{}'.format act the same.
History
Date User Action Args
2014-10-03 20:23:18terry.reedysetrecipients: + terry.reedy, mark.dickinson, eric.smith, docs@python, Barium
2014-10-03 20:23:18terry.reedysetmessageid: <1412367798.18.0.799214799623.issue22546@psf.upfronthosting.co.za>
2014-10-03 20:23:18terry.reedylinkissue22546 messages
2014-10-03 20:23:17terry.reedycreate