Returns a string containing a formatted number.

The format for the $FNUMBER function is:

$FN[UMBER](numexpr,expr[,intexpr])

The numeric expression specifies the number that $FNUMBER() formats.

The expression (second argument) specifies zero or more single character format control codes; if the expression contains any character other than the defined codes, $FNUMBER() generates a run-time error.

The optional integer expression (third argument) specifies the number of digits after the decimal point. If the numeric expression has more digits than specified by this argument, $FNUMBER() rounds to obtain the result. If the numeric expression has fewer digits than specified by this argument, $FNUMBER() zero-fills to obtain the result.

When the optional third argument is specified and the first argument evaluates to a fraction between -1 and 1, $FNUMBER() returns a number with a leading zero (0) before the decimal point (.).

$FNUMBER() formats or edits numbers, usually for reporting. For more information on rounding performed by $FNUMBER(), refer to “$Justify()”.

The formatting codes are:

+ : Forces a "+" on positive values.

- : Suppresses the "-" on negative values.

, : Inserts commas every third position to the left of the decimal within the number.

T : Represents the number with a trailing, rather than a leading sign; positive numbers have a trailing space unless the expression includes a plus sign (+).

P : Represents negative values in parentheses, positive values with a space on either side; combining with any other code except comma (,) causes a run-time error.

Example:

GTM>do ^fnum fnum; zprint ^fnum set X=-100000,Y=2000 write "SUPPRESS NEGATIVE SIGN:",?35,$FNumber(X,"-"),! write "TRAILING SIGN:",?35,$FNumber(X,"T"),! write "NEGATIVE NUMBERS IN ():",?35,$FNumber(X,"P"),! write "COMMAS IN NUMBER:",?35,$FNumber(X,","),! write "NUMBER WITH FRACTION:",?35,$FNumber(X,"",2),! write "FORCE + SIGN IF POSITIVE:",?35,$FNumber(Y,"+"),! SUPPRESS NEGATIVE SIGN: 100000 TRAILING SIGN: 100000- NEGATIVE NUMBERS IN (): (100000) COMMAS IN NUMBER: -100,000 NUMBER WITH FRACTION: -100000.00 FORCE + SIGN IF POSITIVE: +2000

Example:

set x=$fnumber(x,"-")

This example uses $FNUMBER() to SET x equal to its absolute value.