Contribution: nice floating point number formatting

William Park parkw at better.net
Sat Oct 30 06:33:17 EDT 1999


On Sat, Oct 30, 1999 at 01:00:06AM +0000, David S. Harrison wrote:
> # Returns a nicely formatted string for the floating point number
> # provided.  This number will be rounded to the supplied accuracy
> # and commas and spaces will be added.  I think every language should
> # do this for numbers.  Why don't they?  Here are some examples:
> # >>> print niceNum(123567.0, 1000)
> # 124,000
> # >>> print niceNum(5.3918e-07, 1e-10)
> # 0.000 000 539 2
> # This kind of thing is wonderful for producing tables for
> # human consumption.

It may be good for human eye, but it creates havoc when piped to another
program.




More information about the Python-list mailing list