Contribution: nice floating point number formatting

Russell W. Schmidt idt at ornl.gov
Mon Nov 1 19:48:07 CET 1999


First off - thanks to the original contributor for a nice addition to my 
toolbox.

In article <19991101124124.A903 at Ridcully.home>, "Malcolm Tredinnick" 
<malcolmt at smart.net.au> wrote:
>On Sun, Oct 31, 1999 at 05:41:26PM +0100, Carel Fellinger wrote:
>> And for the spaces in the decimal part, are you shure that is conventional?
>> I can't remember having seen this *ever* in my life. At least not in my life
>> as a programmer.
>
>There is a convention in some situations/places where the comma (or, in
>Europe, the dot) is dropped entirely and a thin space is used (if you are
>typesetting -- something smaller than a normal inter-word space).
>
>You will notice I have couched that last paragraph somewhat cautiously: my
>recollection is that this situation (using spaces) is meant to be standard,
>these days but since everybody is used to using commas, etc, they still
>appear quite frequently. IMVHO, the spaces every three digits look nicer
>than throwing a bunch of punctuation marks at the number. :-)
>
>(and if that doesn't start some sort of religious war, I don't know what
>will.) :-)
>

The spaces every three digits, on both sides of the decimal point, are indeed 
part of an international standard, called the International System of Units 
(the Metric System to most Americans).  You can fnd a US reference to it on 
the NIST (National Institute of Standards and Technology) web site. It is 
specifically called out in NIST Special Publication 811 (1995 Edition) "Guide 
for the Use of the International System of Units (SI)".  See section 10.5.3, 
Grouping Digits. The authors note that chapter 10 is adapted in part from ISO 
31-0 and ISO 31-11. 

I will not type in the whole section (pull it from NIST if you care), but the 
short summary in their "Check List for Reviewing Manuscripts" says:

  "The digits of numerical values having more than four digits on either 
    side of the decimal marker are separated into groups of three using a
    thin, fixed space counting from both the left and right of the decimal 
    marker. For example, 15 739.012 53 is highly preferred to 15739.01253.
    Commas are not to be used to separate digits into groups of three."


--
Russ Schmidt         (idt at ornl.gov)
Lockheed Martin Energy Systems, Inc.
Oak Ridge, Tennessee     37831-2009




More information about the Python-list mailing list