[docs] [issue27720] decimal.Context.to_eng_string wrong docstring

Antti Haapala report at bugs.python.org
Thu Aug 11 03:51:07 EDT 2016


Antti Haapala added the comment:

Raymond: your doc patch is not quite right. Decimal('123e1') is converted to Decimal('1.23e3') internally already; so that str(d) will print 1.23e3, scientific notation of that number is '1.23e3' and engineering notation is '1.23e3', thus not a good example. A better example would be  Also, the engineering notation is a string, not a Decimal instance.

Also, now that I test it, the whole `to_eng_string` seems to be utterly broken, same applies to "to_sci_string". They do not print in scientific notation if the exponent in the original number was 0:

    decimal.Decimal('123456789101214161820222426.0e0').to_eng_string()

And all operations with decimal will now generate numbers with exponent of 0 if it is within their precision, so no engineering notation is ever printed, duh.

----------

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


More information about the docs mailing list