Class: Number
Description
This method returns a formatted version of a number.
Syntax
NumberObject.fnumber(String formatCodes,Number decimal)
Parameters
formatCodes |
A string of characters to control the result. Valid values include any combination of the following codes. Invalid characters or invalid combinations will throw a runtime error. P Represent negative values in parentheses, and positive values with a space on either side. This option can only be combined with ",". All other combinations throw an exception. T Represent the number with a trailing sign, rather than a leading sign. Positive numbers have a trailing space. + Force the "+" symbol in front of positive values. - Suppress the minus sign on negative values. , Insert commas every three places before the decimal point. |
decimal |
The number of decimal places to include in the formatted number. If this parameter is present, the number is rounded to the nearest value with the specified number of decimals before formatting is applied. If this value is not specified, formatting is applied to the canonical representation of the number. |
Returns
A String.
When Became Available
Profile v7.0
Example
// A positive and a negative value to demonstrate behavior
type Number POS = 12345678.9876
type Number NEG = -98765432.1234
Type String P1 = POS.fnumber("P",2) // " 12345678,99 "
Type String N1 = NEG.fnumber("P",2) // "(98765432,12)"
Type String P2 = POS.fnumber(",T",2) // "12,345,678.99 "
Type String N2 = NEG.fnumber(",T",2) // "98,765,432.12-"
Type String P3 = POS.fnumber(",T+",2) // "12,345,678.99+"
Type String N3 = NEG.fnumber(",T+",2) // "98,765,432.12-"
Type String P4 = POS.fnumber("+-",2) // "+12345678.99"
Type String N4 = NEG.fnumber("+-",2) // "98765432.12"
// return absolute value of number (note: as a String!)
Type String PABS = POS.fnumber("-") // "12345678.9876"
Type String NABS = NEG.fnumber("-") // "98765432.1234"