Mark Dickinson <dicki...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8060>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to