cbjessup / prettytable

Automatically exported from code.google.com/p/prettytable
Other
0 stars 0 forks source link

%Ng formatting for floats not available as an option #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The differences between %f and %g are described here:

http://stackoverflow.com/questions/5913102/what-is-the-difference-between-g-and-
f-in-c

I am attaching a simple program to illustrate some differences on real data.

Here is the output:

+---------------+------------------+--------------+-------------+
|       default |        floatFmt1 |    floatFmt2 |        gFmt |
+---------------+------------------+--------------+-------------+
| 123456789.123 | 123456789.123400 | 123456789.12 | 1.23457e+08 |
|      0.000122 |         0.000122 |         0.00 |    0.000122 |
|            23 |        23.000000 |        23.00 |          23 |
|    1.01010101 |         1.010101 |         1.01 |      1.0101 |
+---------------+------------------+--------------+-------------+

Original issue reported on code.google.com by and...@andrewschein.com on 24 Nov 2013 at 7:16

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for this report.  Part of the planned changes for the next release of 
PrettyTable is to introduce better support for various kinds of formatting 
(e.g. exponential notation, hexadecimal, etc.).  I'll make sure that the %g 
style is readily available.

Original comment by luke@maurits.id.au on 24 Nov 2013 at 7:27