[issue26223] decimal.to_eng_string() does not implement engineering notation in all cases.

Mark Dickinson report at bugs.python.org
Thu Jan 28 03:07:25 EST 2016


Mark Dickinson added the comment:

I also agree that we shouldn't change the current code. As Raymond says, it may be worth a doc change.

Serge: I was confused by your initial report. If I understand the StackOverflow question correctly, this isn't about the output for *infinite* numbers (e.g., `Decimal('inf')` and `Decimal('-inf')`), and I'm not sure what that would mean. Rather, it's about the output for small finite numbers, where an exponent wouldn't be used in the normal scientific notation. So some people would (understandably) rather see:

>>> Decimal('123456').to_eng_string()
'123.456e3'
>>> Decimal('0.02').to_eng_string()
'20e-3'

than the current

>>> Decimal('123456').to_eng_string()
'123456'
>>> Decimal('0.02').to_eng_string()
'0.02'

for example. Is that what you meant? 

Stefan: IEEE 754 does cover formatting (in section 5.12, "Details of conversion between floating-point data and external character sequences"), but has nothing to say about engineering formats.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26223>
_______________________________________


More information about the Python-bugs-list mailing list