[issue36622] Inconsistent exponent notation formatting

2019-04-14 Thread Mark Dickinson
Mark Dickinson added the comment: FWIW, here's where that "at least two digits" is encoded in the CPython source: https://github.com/python/cpython/blob/bf94cc7b496a379e1f604aa2e4080bb70ca4020e/Python/pystrtod.c#L1227 *If* we wanted to, it would be an easy change to get rid of the extra leadi

[issue36622] Inconsistent exponent notation formatting

2019-04-14 Thread Mark Dickinson
Mark Dickinson added the comment: Indeed it's deliberate. When the Decimal type was introduced, the "at least two exponent digits" behaviour of float formatting was already long established. But the specification that the Decimal type was based on (and the extensive test cases from the same

[issue36622] Inconsistent exponent notation formatting

2019-04-14 Thread Stefan Krah
Stefan Krah added the comment: Yes, I'd think the decisions are deliberate. Floats follow printf(), this is from the manual for 'e': "The exponent always contains at least two digits; if the value is zero, the exponent is 00." And decimal follows the specification at http://speleotrove.

[issue36622] Inconsistent exponent notation formatting

2019-04-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Seems this has tests at https://github.com/python/cpython/blob/830b43d03cc47a27a22a50d777f23c8e60820867/Lib/test/test_decimal.py#L941 . I also noticed the below. Considering this is the behavior from 2.7 is it a conscious design decision? >>> '{:.

[issue36622] Inconsistent exponent notation formatting

2019-04-12 Thread Eric V. Smith
Change by Eric V. Smith : -- nosy: +eric.smith, mark.dickinson, skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue36622] Inconsistent exponent notation formatting

2019-04-12 Thread Sep Dehpour
New submission from Sep Dehpour : Floats and Decimals have inconsistent exponent notation formatting: >>> '{:.5e}'.format(Decimal('2.0001')) '2.00010e+0' >>> '{:.5e}'.format(2.0001) '2.00010e+00' This is causing issues for us since we use the scientific notation formatted string of numbers to