Commatizing numbers: Difference between revisions

m
added whitespace and bullets, consolidated some statements.
m (added some verbage and whitespace (and other improvements) to the Rosetta Code task preamble.)
m (added whitespace and bullets, consolidated some statements.)
Line 11:
 
The number may be part of a larger (non-numeric) string such as:
::::*   «US$1744 millions»       ──or──
::::*   ±25000 motes.
 
The string may possibly ''not'' have a number suitable for commatizing, so it should be untouched and ''no error generated''.
Line 24:
Any &nbsp; ''period'' &nbsp; (<big>.</big>) &nbsp; in a number is assumed to be a &nbsp; ''decimal point''.
 
The original string is never changed &nbsp; ''except'' &nbsp; by the addition of commas &nbsp; [or whatever character(s) is/are used for insertion], if at all.
 
LeadingTo signs ('''+'''wit, '''-''')the arefollowing toshould be preserved (even superfluous signs).:
 
::* &nbsp; leading signs ('''+''', '''-''') &nbsp; &nbsp; &nbsp; ── even superfluous signs
Leading::* &nbsp; leading/trailing/imbeddedembedded blanks, tabs, and other whitespace are to be preserved.
 
The::* &nbsp; the case (upper/lower) of the exponent indicator, is to be preserved. &nbsp; Ee.g.: &nbsp; 4.8903d-002
::: E.G.: &nbsp; +1024 &nbsp; &nbsp; &nbsp; bottles of beer on the wall.
 
The case (upper/lower) of the exponent indicator is to be preserved. &nbsp; E.g.: &nbsp; 4.8903d-002
 
Any exponent character(s) should be supported:
::::::* &nbsp; 1247e12
::::::* &nbsp; 57256.1D-4
::::::* &nbsp; 4444^60
::::::* &nbsp; 7500∙10**35
::::::* &nbsp; 8500x10**35
::::::* &nbsp; +55000↑3
::::::* &nbsp; 1000**100
::::::* &nbsp; 2048²
::::::* &nbsp; 4096<sup>32</sup>
::::::* &nbsp; 10000pow(pi)
 
Numbers may be terminated with any non-digit character, including subscripts and/or superscript: &nbsp; 4142135624² &nbsp; or &nbsp; 7320509076<sub>(base 24)</sub>.
 
The character(s) to be used for the comma can be specified, and may contain blanks, tabs, and other whitespace characters, as well as multiple characters. &nbsp; The default is the comma (<big>''','''</big>) character.
character.
 
The &nbsp; ''period length'' &nbsp; can be specified &nbsp; (sometimes referred to as "thousands" or "thousands separators). &nbsp; The &nbsp; ''period length'' &nbsp; can be defined as the length (or number) of the decimal digits between commas. &nbsp; The default period length is &nbsp; <big>3</big>.
 
::: E.G.: &nbsp; in this example, the &nbsp; ''period length'' &nbsp; is five: &nbsp; 56789,12340,14148
 
The location of where to start the scanning for the target field (the numeric part) should be able to be specified. &nbsp; The default is &nbsp; <big>1</big>.
 
The character strings below may be placed in a file (and read) or stored as simple strings within the program.
Line 63 ⟶ 60:
<br>the Zimbabwe dollar amount should use a decimal point for the "comma" separator:
 
::::* &nbsp; pi=3.14159265358979323846264338327950288419716939937510582097494459231
::::* &nbsp; The author has two Z$100000000000000 Zimbabwe notes (100 trillion).
::::* &nbsp; "-in Aus$+1411.8millions"
::::* &nbsp; ===US$0017440 millions=== (in 2000 dollars)
::::* &nbsp; 123.e8000 is pretty big.
::::* &nbsp; The land area of the earth is 57268900(29% of the surface) square miles.
::::* &nbsp; Ain't no numbers in this here words, nohow, no way, Jose.
::::* &nbsp; James was never known as 0000000007
::::* &nbsp; Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.
::::* &nbsp; ␢␢␢$-140000±100 millions.
::::* &nbsp; 6/9/1946 was a good year for some.
<br>where the penultimate string has three leading blanks &nbsp; (real blanks are to be used).
 
;Also see:
* The Wiki entry: &nbsp; [http://en.wikipedia.org/wiki/Eddington_number Arthur Eddington's number of protons in the universe]. <br><br>
 
 
=={{header|D}}==