Anonymous user
Commatizing numbers: Difference between revisions
m
added whitespace to the task's preamble.
m (→{{header|REXX}}: corrected a typo.) |
m (added whitespace to the task's preamble.) |
||
Line 3:
''Commatizing'' numbers (as used here, a handy expedient made-up word) is the act of adding commas to a number (or string), or the numeric part of a larger string.
;Task:▼
▲;Task:
Write a function that takes a string as an argument with optional arguments or parameters (the format of parameters/options is left to the programmer) that in general, adds commas (or some
other characters, including blanks or tabs) to the first numeric part of a string (if it's suitable for commatizing as per the rules below), and returns that newly commatized string.
Line 14:
::::* ±25000 motes.
The string may possibly ''not'' have a number suitable for commatizing, so it should be untouched and ''no error generated''.
Line 32 ⟶ 33:
::* the case (upper/lower) of the exponent indicator, e.g.: 4.8903d-002
<br>
Any exponent character(s) should be supported:
::::::* 1247e12
Line 44 ⟶ 46:
::::::* 10000pow(pi)
<br>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.
Line 55 ⟶ 57:
The character strings below may be placed in a file (and read) or stored as simple strings within the program.
\
▲<br><br>
;Strings to be used as a minimum:
The value of pi should be separated with blanks every 5 places past the decimal point,
Line 72 ⟶ 75:
:* 6/9/1946 was a good year for some.
<br>where the penultimate string has three leading blanks (real blanks are to be used).
;Also see:
|