Anonymous user
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 ''period'' (<big>.</big>) in a number is assumed to be a ''decimal point''.
The original string is never changed ''except'' by the addition of commas [or whatever character(s) is/are used for insertion], if at all.
::* leading signs ('''+''', '''-''') ── even superfluous signs
▲The case (upper/lower) of the exponent indicator is to be preserved. E.g.: 4.8903d-002
Any exponent character(s) should be supported:
::::::* 1247e12
::::::* 57256.1D-4
::::::* 4444^60
::::::* 7500∙10**35
::::::* 8500x10**35
::::::* +55000↑3
::::::* 1000**100
::::::* 2048²
::::::* 4096<sup>32</sup>
::::::* 10000pow(pi)
Numbers may be terminated with any non-digit character, including subscripts and/or superscript: 4142135624² or 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. The default is the comma (<big>''','''</big>) character.
The ''period length'' can be specified (sometimes referred to as "thousands" or "thousands separators). The ''period length'' can be defined as the length (or number) of the decimal digits between commas. The default period length is <big>3</big>.
::: E.G.: in this example, the ''period length'' is five: 56789,12340,14148
The location of where to start the scanning for the target field (the numeric part) should be able to be specified. The default is <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:
<br>where the penultimate string has three leading blanks (real blanks are to be used).
;Also see:
* The Wiki entry: [http://en.wikipedia.org/wiki/Eddington_number Arthur Eddington's number of protons in the universe]. <br><br>
=={{header|D}}==
|