[issue32790] Keep trailing zeros in precision for string format option g
Severin Wünsch
report at bugs.python.org
Wed Feb 7 21:08:36 EST 2018
New submission from Severin Wünsch <SWuensch at gmail.com>:
The documentation starts the the string format parameter 'g':
General format. For a given precision p >= 1, this rounds the number to **p significant digits** and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude.
I think the behavior of format is inconsistent here:
>>> format(0.1949, '.2g')
returns '0.19' as expected but
>>> format(0.1950, '.2g')
returns '0.2' instead of '0.20'
This behavior for float is in my opinion the correct one here
>>> format(0.1950, '.2f')
returns '0.20'
----------
messages: 311813
nosy: sk1d
priority: normal
severity: normal
status: open
title: Keep trailing zeros in precision for string format option g
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32790>
_______________________________________
More information about the Python-bugs-list
mailing list