[issue23460] Decimals do not obey ':g' exponential notation formatting rules

Lorenz Mende report at bugs.python.org
Sun Sep 2 04:02:24 EDT 2018


Lorenz Mende <lorenz.mende at gmail.com> added the comment:

I want to bring this issue up again.
As the others correctly stated, either the documentation or the implementation of Decimal 'g' formatting is incorrect.

For floats the implementation suits the docu:
>>> '{:g}'.format(0.00001)
'1e-05'
For decimals:
>>> '{:g}'.format(decimal.Decimal('0.00001'))
'0.00001'

As there is a deviation between documentation and implementation, I advise to modify one of both.

----------
nosy: +LorenzMende

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue23460>
_______________________________________


More information about the Python-bugs-list mailing list