New submission from Severin Wünsch <swuen...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue32790>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to