Contents: | Main | Chapter | See Also: | Getting Started Manual | Advanced User Manual |
Formats a number to a string that will separate billions, millions, and thousands with commas.
X |
(Required) The number you want to format. X may be positive or negative. |
X2 |
(Optional) The number of decimal digits you want the output to have. If X2 is not defined, two decimal digits are returned. If X2 is a number followed by the dollar sign (e.g., 3$) then a dollar sign will be prefixed to X before it is output. |
X3 |
(Optional) The length of the desired output. If X3 is less than the formatted X, X3 will be ignored. If X3 is not defined, then a length of twelve is used. |
X |
The initial value of X, formatted with commas, rounded to the number of decimal digits specified in X2. If X2 contained a dollar sign, then the dollar sign will be next to the leftmost digit. If X was negative, then the returned value of X will be in parentheses. If X was positive, a trailing space will be appended. If necessary, X will be padded with leading spaces so that the length of X will equal the value of the X3 input variable. |
Example 1
>S X=12345.678 D COMMA^%DTC
The result is:
X=" 12,345.68 "
Example 2
>S X=9876.54,X2="0$" D COMMA^%DTC
The result is:
X=" $9,877 "
Example 3
>S X=-3,X2="2$" D COMMA^%DTC
The result is:
X=" ($3.00)"
Example 4
>S X=12345.678,X3=10 D COMMA^%DTC
The result is:
X="12,345.68 "
Reviewed/Updated: March 8, 2007