This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients eric.smith, ezio.melotti, hardkrash, mark.dickinson, r.david.murray, terry.reedy
Date 2010-04-27.18:03:59
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1272391442.47.0.100600980759.issue8060@psf.upfronthosting.co.za>
In-reply-to
Content
After the all-important issue of what letter to use (the folks on the python-list thread suggested 'm', and it seems as good a letter as any, so I'll use it in the examples below), there are some open questions:

(1) The exact form of the output needs to be determined.  For a nonzero finite number, I'm guessing the output should look something like:

'<sign><digits>.<digits>e<exponent>

with at least 1 and at most 3 digits to the left of the point (and the first of those digits being nonzero).  Is this about right?  The sign would be controlled in the same way as for 'e', 'f' and 'g' formatting.  Would the exponent be included even when it's zero, or should it be omitted in that case?

(We'd need to determine how to output zeros, nans and infinities, too, but that shouldn't be a big issue.)

(2) When doing something like 'format(x, '.5m')', what would the 5 refer to?  The two options I see are (a) number of significant digits, or (b) number of digits to the right of the point.  The former seems to make more sense mathematically, but might be a bit awkward when it comes to aligning results in a table:

format(3.2, '.5m')  -> 3.20000e+00
format(13.2, '.5m') -> 13.2000e+00

The latter results in different numbers of significant digits depending on where the exponent lies.

Hmm.  Perhaps there's also (c):  number of places to the right of the *true* decimal point, so that 'm' is more analogous to 'f' than to 'e'.

(3) What should the default precision be?  6 is what's used for 'e', 'f' and 'g' formatting, so should probably also be used for 'm'.

(4) When (if ever) should trailing zeros and a trailing decimal point be omitted (like 'g' formatting does).  I'd say never.

(5) What should the decimal module do?  Call to_eng_string, or try to match float's behaviour?  Formatting for the decimal type has the added complication of trying to preserve significant zeros where possible;  this might require some thought.
History
Date User Action Args
2010-04-27 18:04:02mark.dickinsonsetrecipients: + mark.dickinson, terry.reedy, eric.smith, ezio.melotti, r.david.murray, hardkrash
2010-04-27 18:04:02mark.dickinsonsetmessageid: <1272391442.47.0.100600980759.issue8060@psf.upfronthosting.co.za>
2010-04-27 18:04:00mark.dickinsonlinkissue8060 messages
2010-04-27 18:03:59mark.dickinsoncreate